Search code examples
javawekalibsvm

WEKA + Java: get class probabilities


Given the following binary classifier:

LibSVM classifier = new LibSVM();
classifier.setCost(cost);
classifier.setGamma(gamma);

performing the following operation returns the label for the instance:

double classId = classifier.classifyInstance(instance);

However, I would like to obtain the degree of confidence for this classification (i.e., probability that the instance is in the positive class + probability that the instance is in the negative class).

How can I obtain this information? Is it possible to have it?

Thanks.


Solution

  • Have you considered using SetProbabilityEstimates(), which sets a flag for generating probability estimates?

    There is also another option, -B, in SetOptions() that may help you generate these probability estimates.