简体   繁体   English

使用不同分类器的 sklearn precision_recall_curve 函数

[英]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.我有一个二进制数据集,正在使用三个分类器( SVMRFLR )对其进行分类。

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_functionSVM分类器的内置函数。 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.

相关问题 使用 precision_recall_curve 计算最大 f1 分数? - compute maximum f1 score using precision_recall_curve? 在scikit的precision_recall_curve中,为什么阈值与召回和精确度有不同的维度? - In scikit's precision_recall_curve, why does thresholds have a different dimension from recall and precision? python - 为不同的多类分类器绘制精度召回曲线 - python - Plot Precision Recall Curve for different multi-class classifiers 如何在sklearn.metrics中为函数precision_recall_curve和roc_curve获得相同的阈值 - How to get the same thresholds values for both functions precision_recall_curve and roc_curve in sklearn.metrics 为什么precision_recall_curve() 返回的值与混淆矩阵不同? - Why does precision_recall_curve() return different values than confusion matrix? precision_recall_curve 曲线仅返回单个值 - precision_recall_curve curve is returning only single value 输入到precision_recall_curve-预测还是predict_proba输出? - Input to precision_recall_curve - predict or predict_proba output? 使用 sklearn 获得精度和召回率 - Getting Precision and Recall using sklearn 不同阈值下的特异性(与 sklearn.metrics.precision_recall_curve 相同) - Specificity at different thresholds (in the same way as sklearn.metrics.precision_recall_curve) 绘制阈值(precision_recall 曲线)matplotlib/sklearn.metrics - Plotting Threshold (precision_recall curve) matplotlib/sklearn.metrics
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM