【发布时间】:2018-02-24 23:16:20
【问题描述】:
目标:获得一类的precision和recall(y_true = 1)
背景:我检查了http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html#sklearn.metrics.precision_recall_curve,它指出pos_label 是positive class 的标签,默认设置为1。
问题:
1) 如果我只想要positive class 的precision 和recall(在这种情况下为y_true = 1)我应该保留pos_label = 1 还是应该将其更改为pos_label = 0?
2) 或者有没有更好的方法来实现我的目标?
下面我在pos_label = 0时显示代码
import numpy as np
from sklearn.metrics import precision_recall_fscore_support
y_true = np.array(['0', '1', '1', '0', '1'])
y_pred = np.array(['1', '0', '1', '0', '1'])
out = precision_recall_fscore_support(y_true, y_pred, average='weighted', pos_label = 0)
【问题讨论】:
-
相当肯定 pos_label 应该是 1。你总是可以运行代码和calculate precision and recall by hand。
-
您是否尝试过使用classification_report?
-
我使用了分类报告。但问题是获得
one-class.的分数我使用什么target-names?或者你会建议我如何完成这个? -
一类是什么意思?分类报告默认会单独输出所有类的指标
标签: python machine-learning scikit-learn precision-recall