7

I am using libsvm for multi-class classification. How can I attach classification scores, to compare the confidence of classification, with the output for a given sample as:

Class 1: score1

Class 2: score2

Class 3: score3

Class 4: score4
Xolve
  • 22,298
  • 21
  • 77
  • 125
  • I do not want a single class id as the classification output. Rather the output should be like: the given sample can be classified to class1 with probability score1. – Xolve Jun 18 '11 at 18:26

2 Answers2

6

You can use one vs all approach first and consider them as 2class classification by having the decision value option in the libSVM. This is done by having the each class as positive class and rest of the class as negative for each classification.

Then compare the decision values of the results to classify the samples. Like you can assign the sample to the class which has the highest decision values. For example, sample 1 has decision value 0.54 for class 1, 0.64 for class 2, 0.43 for class 3 and 0.80 for class4, then you can classify it to class4.

You can also use probability values to classify instead of decision function values by using -b option in libSVM.

Hope this helps..

Mullaly
  • 320
  • 4
  • 18
  • Normalizing the distance to the hyperplane isn't always a good measurement of probability of belonging to a class. See [this paper](http://www.research.ibm.com/people/z/zadrozny/kdd2002-Transf.pdf) by Zadrozny and Elkan. – David C Aug 03 '12 at 15:24
2

Another option is to use the LIBLINEAR package which internally implements one-vs-all strategy for solving multi-class problem. In LIBSVM, this implementation is based on one-vs-one strategy.

Ayan
  • 41
  • 1
  • 6