July 2017
Beginner to intermediate
715 pages
17h 3m
English
We can also test an individual instance using the classifyInstance method. In the following sequence, we create a new instance using the DenseInstance class. It is then populated using the attributes of the camping dataset:
Instance instance = new DenseInstance(3); instance.setValue(data.attribute("age"), 78); instance.setValue(data.attribute("income"), 125700); instance.setValue(data.attribute("camps"), 1);
The instance needs to be associated with the dataset using the setDataset method:
instance.setDataset(data);
The classifyInstance method is then applied to the smo instance and the results are displayed:
System.out.println(smo.classifyInstance(instance));
When executed, we get the following output: