I hava a problem with classifying a single instance in WEKA, here is my code :
public void addInstance() throws Exception {
Scanner s = new Scanner(System.in);
DenseInstance newInstance = new DenseInstance(m_Training.numAttributes());
for(int i = 0 ; i < m_Training.numAttributes()-1 ; i++)
{
double value = s.nextDouble();
newInstance.setValue(i , value);
//i is the index of attribute
//value is the value that you want to set
}
newInstance.setValue(m_Training.numAttributes()-1, Float.NaN);
//add the new instance to the main dataset at the last position
m_Training.add(newInstance);
// Print header and instances.
System.out.println("\nDataset:\n");
System.out.println(m_Training);
System.out.print("\n\nClassification result : ");
System.out.println(m_Classifier.classifyInstance(m_Training.instance(150)));
System.out.println(m_Training.instance(150));
System.out.println(m_Training.classAttribute().value((int)m_Classifier.classifyInstance(m_Training.instance(150))));
}
But it always give a result of 0.0. I have read this tutorial : weka: how to get class name from testing single instance but still, the program gives me only 0.0 and the class name is always "iris-setosa".
I used Iris.arff for this program and the classifier(m_classifier) is J48. I don't know why it's not working, any help appreciated