目标:获取一流(grepl("^[-]{0,1}[0-9]{0,}.{0,1}[0-9]{1,}$", xx)
= precision
)的recall
和y_true
背景:我检查了http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html#sklearn.metrics.precision_recall_curve,并指出1
是pos_label
的标签,默认设置为positive class
。
问题:
1)如果我只希望我1
precision
recall
(在这种情况下为positive class
= y_true
),我应保留{{1 }} = 1
还是应该将其更改为pos_label
?
2)或者是否有更好的方法来实现目标?
下面我在1
= pos_label = 0
pos_label
答案 0 :(得分: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'])
#keep 1's
y_true, y_pred = zip(*[[ytrue[i], ypred[i]] for i in range(len(ytrue)) if ytrue[i]=="1"])
out = precision_recall_fscore_support(y_true, y_pred, average='micro')