Ask Your Question

OpenCV SVM prediction probability

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

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.

Any advances on this?

edit retag flag offensive close merge delete


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 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

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

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;
   cout << "Prediction result " << output << endl;
edit flag offensive delete link more


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

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

Question Tools



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

Seen: 2,128 times

Last updated: Feb 14 '17