【问题标题】:Enable Probability Estimates in scikit.smv.SVC based on LIBSVM在基于 LIBSVM 的 scikit.smv.SVC 中启用概率估计
【发布时间】:2018-06-19 02:44:53
【问题描述】:

在 LIBSVM 中,svmtrain 中的 -b 标志用于启用 SVC 或 SVR 模型的概率估计训练。为了得到测试集对应的结果,我们还将-b的结果设置在svmpredict

例如,在 MATLAB 中,我们将编写以下代码来训练和测试启用概率估计:

model = svmtrain(train_labels, train_set, '-b 1')
[result, accuracy, prob] = svmpredict(test_labels, test_set, '-b 1')

但是,在 scikit-learn 库中初始化 SVC 时,我们只能在训练时设置 -b 标志,这与在 svmtrain 上设置 -b 标志相同:

clf = scikit.svm.SVC(probability=True)

为了在 scikit-learn 中进行测试,我使用 clf.predict(test_set) 来获取课程。但是,当我将svmpredict-b 1 标志一起使用时,这会产生不同的结果。

在使用svmpredict 进行测试期间设置-b 标志的scikit-learn svm 中的等效项是什么?

【问题讨论】:

  • 是的,这是预期的,因为 predict() 不使用概率。它在此处的文档中提到:scikit-learn.org/dev/modules/svm.html#scores-and-probabilities

标签: scikit-learn svm libsvm


【解决方案1】:

Scikit-learn 不使用标志来预测分类器的概率,有一个额外的函数可用,称为 .predict_proba。看看documentation

概率是使用Platt scaling 确定的,这是一种将分类器的任意输出组合成类概率的方法。

也可以在这里查看答案:How does sklearn.svm.svc's function predict_proba() work internally?

【讨论】:

    猜你喜欢
    • 2014-08-11
    • 2011-12-09
    • 2014-04-07
    • 2014-03-18
    • 2015-05-06
    • 2013-02-02
    • 2012-12-06
    • 2013-05-18
    • 2021-03-14
    相关资源
    最近更新 更多