当我们使用 sklearn.metric.classification_report 工具对模型的测试结果进行评价时,会输出如下结果:
对于 精准率(precision )、召回率(recall)、f1-score,他们的计算方法很多地方都有介绍,这里主要讲一下micro avg、macro avg 和weighted avg 他们的计算方式。
1、宏平均 macro avg:
对每个类别的 精准、召回和F1 加和求平均。
精准 macro avg=(P_no+P_yes)/2=(0.24+0.73)/2 = 0.48
2、微平均 micro avg:
不区分样本类别,计算整体的 精准、召回和F1
精准 macro avg=(P_no*support_no+P_yes*support_yes)/(support_no+support_yes)=(0.24*7535+0.73*)/(7535+22462)=0.45
3、加权平均 weighted avg:
是对宏平均的一种改进,考虑了每个类别样本数量在总样本中占比
精准 weighted avg =P_no*(support_no/support_all)+ P_yes*(support_yes/support_all =0.24*(7525/29997)+0.73*(22462/29997)=0.61
参考资料:
https://blog.csdn.net/weixin_43922901/article/details/106097774