0

I am doing a classification task (-1 and +1) using LIBSVM in JAVA. In LIBSVM i use kernel_type=RBF and svm_type=C_SVC and all other parameter value are default.

How do I rank output of svm_predict() in java?

svm_predict() generates this file:

 labels 1 -1
-1.0 0.019641780896603997 0.9803582191033958 
-1.0 0.021318683904391962 0.9786813160956079 
-1.0 0.01977828600663557 0.9802217139933644 
-1.0 0.0282631732179981 0.9717368267820019 
-1.0 5.286175141886943E-7 0.9999994713824858 
-1.0 0.004980730957033338 0.9950192690429667 
-1.0 0.004500990037742634 0.9954990099622574 
-1.0 0.013496219124888747 0.9865037808751113 
-1.0 0.0033941767601432665 0.9966058232398568 
-1.0 0.004436071705624729 0.9955639282943753 
-1.0 2.425758250037033E-10 0.9999999997574243 
-1.0 5.4261670963815676E-8 0.999999945738329 
-1.0 4.736895864616017E-9 0.9999999952631042 
-1.0 1.3239231249757209E-5 0.9999867607687501 
-1.0 2.3084949252003764E-7 0.9999997691505075

I follow these steps for ranking:

d=Math.abs( label(1) - label(-1) ) 

(e.g. 0.96071=0.01964 - 0.98035)

rank=d/2 

(e.g. rank=0.4803)

Kate Gregory
  • 18,808
  • 8
  • 56
  • 85
Somnath Kadam
  • 6,051
  • 6
  • 21
  • 37
  • What do you mean by "rank" here? What are you trying to do? BTW, you will be lucky to get good results with default values of the c and g parameters - you need to do a grid search using validation to find good parameters. – Bull May 18 '13 at 13:43
  • 1
    Suppose i want to retrieve positive images, and SVM gives me 10 Images (8 positive and 2 negative). From that 8 positive images, how to rank most relevant images? Just like in any CBIR(Content Based images retrieval) system, it gives most relevant images. – Somnath Kadam May 20 '13 at 18:00

1 Answers1

2

svm_predict() is giving you the probability that each image is positive, (in second column). Just rank your images in order of that probability.

Your calculation is equivalent to rank=Math.abs( label(1) - 0.5 ). It is hard to see how this is useful as probabilities close to zero end up bigger than those that are above 0.5

Bull
  • 11,771
  • 9
  • 42
  • 53