![](/img/trans.png)
[英]Accuracy for each probability cutoff in a binary classification problem (python sklearn accuracy)
[英]Why sklearn returns the accuracy and weighted-average recall the same value in binary classification?
我的问题是一个二元分类,我使用以下代码来获得accuracy
和weighted average recall
。
from sklearn.ensemble import RandomForestClassifier
clf=RandomForestClassifier(random_state = 0, class_weight="balanced")
from sklearn.model_selection import cross_validate
cross_validate(clf, X, y, cv=10, scoring = ('accuracy', 'precision_weighted', 'recall_weighted', 'f1_weighted'))
我注意到accuracy
和weighted average recall
的值是相等的。 但是,据我了解,这两个指标包含两个不同的方面,因此,我不清楚为什么它们完全相等。
我发现了一个有类似问题的帖子: https : //www.researchgate.net/post/Multiclass_classification_micro_weighted_recall_equals_accuracy 。 但是,我没有发现该帖子的答案有用。
如果需要,我很乐意提供更多详细信息。
准确度是:
TP + TN / (P+ N)
因此,让我们假设您有 50 个正类和 50 个负类,不知何故,这是您的正类预测 25 个正确和您的负类预测正确的 25 个,然后:
25 + 25 / (50+50) = 0.5
加权平均召回率:第一次召回率: TP/P = 25/50 = 0.5
加权召回:
(recall_posivite*number_positve)+(recall_negative*number_negative)/(number_positive + number_negativ) = 0.5*50+0.5*50/(50+50) = 50/100 = 0.5
我希望这有助于理解它可能发生!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.