微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

为什么precision_recall_fscore_support返回2个值?

如何解决为什么precision_recall_fscore_support返回2个值?

我是第一次使用precision_recall_fscore_support

precision,recall,fscore,support = score(y_test,y_pred)


print('precision: {}'.format(precision))
print('recall: {}'.format(recall))
print('fscore: {}'.format(fscore))
print('support: {}'.format(support))

但是我每个都有2个值

precision: [0.67420814 0.67032967]
recall: [0.62343096 0.71764706]
fscore: [0.64782609 0.69318182]
support: [239 255]

为什么每个评估都有2个值?

以及如何获得标准的precision / recall / f1score

解决方法

我不确定您在说什么分数,我相信它是sklearn库中的.score(),如果是这样,那么下面就是答案。

Parameters
X : array-like,shape = (n_samples,n_features)
Test samples.
y : array-like,shape = (n_samples) or (n_samples,n_outputs)
True values for X.
sample_weight : array-like,shape = [n_samples],optional
Sample weights.
**Returns**
score : float
either accuracy or R^2 of self.predict(X) wrt. y.

在我看来,您认为o / p中有2个类,因此它返回2个值。 e.x:class1精度为0.67420814,class2为0.67032967

以下链接可能会为您提供帮助,https://www.kite.com/python/docs/sklearn.kernel_ridge.KernelRidge.score

我建议您使用category_report(https://scikit-learn.org/stable/modules/generated/sklearn.metrics.classification_report.html)库,这样可以最大程度地减少工作量。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。