我在EmguCV中使用多类支持向量机分类器。我需要每个类别的支持向量机的信心分数。例如,我不需要支持向量机只声明类号,我需要它告诉我不同类的P(类号\输入)。如何在EmguCV中获得这个概率或分数?(多类)
如果没有方法,那么matlab中的多类支持向量机分类器有何解决方案?
发布于 2015-07-21 10:35:05
我不熟悉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)));
}
}希望能帮上忙!
更新
对于多类情况,请参考以下链接:
https://stackoverflow.com/questions/31534817
复制相似问题