Ask Your Question
1

OpenCV SVM prediction probability

asked 2015-04-21 06:30:40 -0600

Poyan gravatar image

Is it possible to get a prediction's probability along with the prediction when using an SVM in OpenCV?

I found some threads discussing this, but they are all from 2-3 years ago.

http://answers.opencv.org/question/14...

http://stackoverflow.com/questions/16...

Any advances on this?

edit retag flag offensive close merge delete

Comments

I think you shall review this. I have not found a way to "extract" the probability from the prediction of the SVM. What I can tell you, is that if the prediction value is 0 (in the case of returnDFVal=true), it means that the prediction is on the function representation that is separating the classes; so it is the totally confusion case, and the greater the value is, the more representative for a class the sample is.

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-04-21 08:51:16 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-02-14 10:30:11 -0600

TanaseC gravatar image

I know that in the latest version (version 3.2 as of now) you have an int flag param with your predict function. If you set it to 1 it will give you a probability. It should look something like:

   Mat output;
   Mat input = getVector();
   int flag = 1;
   svm->predict(input,output,flag); 
   cout << "Prediction result " << output << endl;
edit flag offensive delete link more

Comments

Prediction result only use for binary classifier .Dont working wiith multiple classifier

vbc gravatar imagevbc ( 2017-10-29 22:24:35 -0600 )edit

Question Tools

3 followers

Stats

Asked: 2015-04-21 06:30:40 -0600

Seen: 3,435 times

Last updated: Feb 14 '17