[英]Using sklearn precision_recall_curve function with different classifiers
This may be an easy question, but I need help understanding how to use the precision_recall_curve
function in sklearn
.这可能是一个简单的问题,但我需要帮助了解如何在
sklearn
使用precision_recall_curve
函数。
I have a binary dataset and am using three classifiers ( SVM
, RF
, LR
) to classify it.我有一个二进制数据集,正在使用三个分类器(
SVM
、 RF
、 LR
)对其进行分类。
The example in sklearn's documentation shows to use the function like this: sklearn 文档中的示例显示使用如下函数:
y_score = classifier.decision_function(X_test)
precision_recall_curve(y_test, y_score)
In the example, decision_function
is a built-in function for SVM
classifiers.在示例中,
decision_function
是SVM
分类器的内置函数。 However, I don't see a function like that for Random Forest classifiers or Linear Regression.但是,我没有看到类似随机森林分类器或线性回归的函数。
Can someone help me understand what the y_score
and decision function really is, and how I can calculate it for any classifier?有人可以帮助我理解
y_score
和决策函数到底是什么,以及我如何为任何分类器计算它?
Thanks!谢谢!
Look at the second param description in documentation of precision_recall_curve
:查看
precision_recall_curve
文档中的第二个参数描述:
probas_pred : array, shape = [n_samples]
probas_pred:数组,形状= [n_samples]
Estimated probabilities or decision function.
估计概率或决策函数。
When decision_function()
is not present, you may use predict_proba()
in its place.当
decision_function()
不存在时,您可以使用predict_proba()
代替它。
对于所有其他没有内置decision_function
,您应该使用predict_proba
函数,它基本上做同样的事情。
y_score = random_forest.predict_proba()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.