I am looking for a way to get the prediction confidence for a multi-class prediction with an opencv SVM. What I found so far:
//data is a cv::Mat containing the samples to be predicted in format (num_samples,dimension,CV_32F)
//SVM_classifier is a trained opencv SVM classifier
cv::Mat predLabels(data.rows,1,CV:32F);
cv::Mat predProb(data.rows,1,CV_32F);
predProb = SVM_classifier->predict(data,predLabels,cv::ml::StatModel::RAW_OUTPUT);
Executing this code, I get pretty good prediction results (Fmeasure around 0.95), but the predProb
matrix only contains '0' ... Can someone help me to get the correct results? Is the issue that I have a multi-class problem instead of a binary problem?
Also what is the difference in using cv::ml::StatModel::RAW_OUTPUT
instead of cv::ml::SVM::Flags::RAW_OUTPUT
? No matter which one I use, I get a vector filled with zeros as result... Any help is appreciated!!