classification_report展示了weighted average F1 Score:需要区分类别,计算每个类别的f1-score,对所有类别的f1-score加权平均,权重为类别对应的样本数量占总样本数量的比例
Micro F1 Score:不需要区分类别,直接使用总体样本计算f1-score
Macro F1 Score:需要区分类别,根据每个类别,分别计算P、R、F1-score,将所有类别的f1-score取平均。
Accuracy :
from sklearn.metrics import f1_score
from sklearn.metrics import classification_report
f1_score([0,0,0,0,1,1,1,2,2], [0,0,1,2,1,1,2,1,2],average="micro")
0.5555555555555556
f1_score([0,0,0,0,1,1,1,2,2], [0,0,1,2,1,1,2,1,2],average="macro")
0.546031746031746
print(classification_report([0,0,0,0,1,1,1,2,2], [0,0,1,2,1,1,2,1,2]))
precision recall