【发布时间】:2015-10-10 15:46:15
【问题描述】:
我在 EmguCV 中使用多类 SVM 分类器。我需要每个类的 SVM 置信度得分。例如,我不需要 SVM 只声明类号,我需要它告诉我不同类的 P(classnumbers| input)。 如何在 EmguCV 中获得这个概率或分数?(多类)
如果没有办法,matlab中多类SVM分类器有什么解决方案吗?
【问题讨论】:
标签: matlab opencv svm emgucv libsvm
我在 EmguCV 中使用多类 SVM 分类器。我需要每个类的 SVM 置信度得分。例如,我不需要 SVM 只声明类号,我需要它告诉我不同类的 P(classnumbers| input)。 如何在 EmguCV 中获得这个概率或分数?(多类)
如果没有办法,matlab中多类SVM分类器有什么解决方案吗?
【问题讨论】:
标签: matlab opencv svm emgucv libsvm
我不熟悉EmguCV,但是在OpenCV 中你可以这样做来获得SVM 中的概率:
CvSVM svm; // declare your classifier;
// then do your training process here
svm.train(featuresToBeTrained, labelsToBeTrained, cv::Mat(), cv::Mat(), params); // params are the svm parameters, you can use libsvm to optimize them.
//libsvm website: https://www.csie.ntu.edu.tw/~cjlin/libsvm/
// perform prediction
double confidenceScore = svm.predict(featuresToBePredected, true); // this will give you a signed distance to the margin.
// Then you can normalize the score to improve it, one best way is to use sigmoid function.
double finalScore = sigmoidFunc(confidenceScore, sigmoidA, sigmoidB); // sigmoidA and sigmoidB are params for sigmoid function, take wikipedia for reference
// You can define sigmoid function like this
double sigmoidFunc(double confidenceScore, double A, double B)
{
double fApB = confidenceScore*A + B;
// 1-p used later; avoid catastrophic cancellation
if (fApB >= 0)
{
return 1.0 - (exp(-fApB) / (1.0 + exp(-fApB)));
}
else
{
return 1.0 - (1.0 / (1.0 + exp(fApB)));
}
}
希望对你有帮助!
更新
对于多类案例,请参考以下链接:
click here
【讨论】: