0
votes

I'm using SMO in classify nominal values. After I build the classifier I need to predict the class for instance but classifyInstance (weka.classifiers.Classifier.classifyInstance) return only double number.

How can I use the double number to get the original nominal class?

1

1 Answers

1
votes

Assuming you are calling the weka classes in your Java code, you'll need to know that internally, Weka handles all values as doubles.

When you create the Attribute, you pass it an array of strings that lists the possible nominal values. The double that classification returns is the index of the chosen attribute in the original array. So if you had code that looked like this:

String[] attributeValues = {"a", "b", "c"};
Attribute a = new Attribute("attributeName", attributeValues);

and classifyInstance() returned 2, then the class it chose would be attributeValues[2] or "c".