【问题标题】:Confidence score or probability in SVMSVM 中的置信度分数或概率
【发布时间】:2015-10-10 15:46:15
【问题描述】:

我在 EmguCV 中使用多类 SVM 分类器。我需要每个类的 SVM 置信度得分。例如,我不需要 SVM 只声明类号,我需要它告诉我不同​​类的 P(classnumbers| input)。 如何在 EmguCV 中获得这个概率或分数?(多类)

如果没有办法,matlab中多类SVM分类器有什么解决方案吗?

【问题讨论】:

    标签: matlab opencv svm emgucv libsvm


    【解决方案1】:

    我不熟悉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

    【讨论】:

    • Tnx 很多德曼 :)。我认为它仅适用于二类分类器,对吗?在 EmguCV 中,没有 DecisionFunction 我可以将其标志设置为 true 很遗憾
    • 我的意思是我无法获得 SVM 的置信度分数
    • 我不认为多类情况与二类情况有很大不同,因为您在训练期间让 SVM 知道您的数据集中有多少类。
    • 是的,你是对的,但是当我选择 SVMType 参数时,我选择了 C-SVC(multi-class) 而不是 One-Class 选项,对于这种类型的 SVM,Predict( featuresToBePredected, true) 不起作用。
    • 这不是一个正确的方法,它没有概率的意义,你应该改用Platt's scaling
    猜你喜欢
    • 1970-01-01
    • 2017-04-29
    • 2021-02-06
    • 1970-01-01
    • 2016-10-03
    • 2013-05-22
    • 1970-01-01
    • 2020-05-23
    • 2015-06-06
    相关资源
    最近更新 更多