We are using Java-ML(LibSVM) in order to execute the SVM algorithm over a multi-class problem
Classifier clas = new LibSVM();
clas.buildClassifier(data);
Dataset dataForClassification= FileHandler.loadDataset(new File(.), 0, ",");
/* Counters for correct and wrong predictions. */
int correct = 0, wrong = 0;
/* Classify all instances and check with the correct class values */
for (Instance inst : dataForClassification) {
Object predictedClassValue = clas.classify(inst);
Map<Object,Double> map = clas.classDistribution(inst);
Object realClassValue = inst.classValue();
if (predictedClassValue.equals(realClassValue))
correct++;
else
wrong++;
}
the classDistributtion() returns a standard vector ( meaning all values are 0 but one value which equals to 1)
java-ml – http://java-ml.sourceforge.net/
Despite the other answers, it is possible to output probability estimates for SVMs and LibSVM does do this. However, I’m fairly sure you can’t use this feature from Java-ML. The file
LibSVM.javaonly ever refers to the functionsvm_predict_valuesand neversvm_predict_probabilities. It probably wouldn’t be too hard to add this functionality in to Java-ML if you felt you really needed it.