精确回忆pos_label python为一流

时间:2018-02-23 18:51:35

标签: python machine-learning scikit-learn precision-recall

目标:获取一流grepl("^[-]{0,1}[0-9]{0,}.{0,1}[0-9]{1,}$", xx) = precision)的recally_true

背景:我检查了http://scikit-learn.org/stable/modules/generated/sklearn.metrics.precision_recall_curve.html#sklearn.metrics.precision_recall_curve,并指出1pos_label的标签,默认设置为positive class

问题

1)如果我只希望我1 precision recall(在这种情况下为positive class = y_true),我应保留{{1 }} = 1还是应该将其更改为pos_label

2)或者是否有更好的方法来实现目标

下面我在1 = pos_label = 0

时显示代码
pos_label

1 个答案:

答案 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')