Search code examples
weka

WEKA: how to get the score from classifyInstance?


I'm using a FilteredClassifier.classifyInstance() to classify my instances in weka.

I have 2 classes (true and false) and I have many positives, so I actually need to know the score of each isntance to get the best positive.

You know how I could get the score from my weka classifier ?

thanks

Update: I've also tried to use distributionForInstance, but for each instance I always get an array with [1.0, 0.0].

I actually need to compare several instances to see which one is the most reliable, which one has more changes to have been classified correctly.


Solution

  • distributionForInstance(Instance anInstance) is the method you need. It gives you a Double array showing the confidence for each of your classes. I am using Weka 3.6. and it works well for me. If you always get the same values, your classifier is not trained well and not discriminative at all. In that case, you should always get the same class predicted. Did you balance your training set?