赞
踩
当β=1时,称为F1-score
这里介绍F1-score的python实现
sklearn.metrics.classification_report
分类报告:sklearn.metrics.classification_report(y_true, y_pred, labels=None, target_names=None,sample_weight=None, digits=2),显示主要的分类指标,返回每个类标签的精确、召回率及F1值
主要参数说明:
labels:分类报告中显示的类标签的索引列表
target_names:显示与labels对应的名称
digits:指定输出格式的精确度
精度(precision) = 正确预测的个数(TP)/被预测为正例的个数(TP+FP)
召回率(recall)=正确预测的个数(TP)/实际正例的个数(TP+FN)
F1 = 2精度召回率/(精度+召回率)
https://blog.csdn.net/kancy110/article/details/74937469?utm_source=blogxgwz3
## Cast linear regression predictions backward to labels.
# Compare them with real labels and print F1 score.
from sklearn.metrics import classification_report
print(classification_report(y_true,y_pred,digits=3))
注意:在二分类中,真正例率也称灵敏度,真负例率也称特效性
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。