首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >支持向量机的置信度或概率

支持向量机的置信度或概率
EN

Stack Overflow用户
提问于 2015-07-21 09:09:12
回答 1查看 1.4K关注 0票数 0

我在EmguCV中使用多类支持向量机分类器。我需要每个类别的支持向量机的信心分数。例如,我不需要支持向量机只声明类号,我需要它告诉我不同类的P(类号\输入)。如何在EmguCV中获得这个概率或分数?(多类)

如果没有方法,那么matlab中的多类支持向量机分类器有何解决方案?

EN

回答 1

Stack Overflow用户

发布于 2015-07-21 10:35:05

我不熟悉EmguCV,但在OpenCV中,您可以这样做以获得SVM中的概率

代码语言:javascript
复制
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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31534817

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档