精确率(Precision)、召回率(Recall)、准确率(Accuracy)、F值(F-Measure)

版权声明:王家林大咖2018年新书《SPARK大数据商业实战三部曲》清华大学出版,微信公众号:从零起步学习人工智能 https://blog.csdn.net/duan_zhihua/article/details/86079932

精确率(Precision)、召回率(Recall)、准确率(Accuracy)、F值(F-Measure) 的理解:
 

例如:对图片猫、狗、兔子进行预测分类,如下图: 

图片为猫,预测分类是猫的图片数:5      
图片为猫,预测分类是狗的图片数:3
图片为猫,预测分类是兔子的图片数:0

图片为狗,预测分类是猫的图片数:2      
图片为狗,预测分类是狗的图片数:3
图片为狗,预测分类是猫的图片数:1

图片为兔子,预测分类是猫的图片数:0      
图片为兔子,预测分类是狗的图片数:2
图片为兔子,预测分类是兔子的图片数:11

  Actual class
Cat Dog Rabbit

Predicted
class

Cat 5 2 0
Dog 3 3 2
Rabbit 0 1 11

那么对于图片猫而言:

TP(True Positives): 图片为猫,预测分类也是猫的图片数:5  
FP(False Positives):  图片不为猫,但是预测分类是猫的图片数:2+0=2
FN( False Negatives):  图片为猫,但预测分类不是猫的图片数:3+0=3
TN(True Negatives):图片不为猫, 预测分类也不是猫的图片数:3+2+1+11=17

  Actual class
Cat Non-cat

Predicted
class

Cat 5 True Positives 2 False Positives
Non-cat 3 False Negatives 17 True Negatives

精确率= 5/ 5+2 = 5/7    {\displaystyle {\text{Precision}}={\frac {tp}{tp+fp}}\,}

召回率= 5/ 5+3 = 5/8  {\displaystyle {\text{Recall}}={\frac {tp}{tp+fn}}\,}

准确率= 5+17 / 5+17+2+3 = 22/27 {\displaystyle {\text{Accuracy}}={\frac {tp+tn}{tp+tn+fp+fn}}\,}

F值= 2*5 / 2*5 + 2+ 3 = 10 / 15    {\displaystyle F_{1}=2\cdot {\frac {\mathrm {PPV} \cdot \mathrm {TPR} }{\mathrm {PPV} +\mathrm {TPR} }}={\frac {2\mathrm {TP} }{2\mathrm {TP} +\mathrm {FP} +\mathrm {FN} }}}

更多的计算详情参考: https://en.wikipedia.org/wiki/Confusion_matrix

  

 cs224 的作业:

猜你喜欢

转载自blog.csdn.net/duan_zhihua/article/details/86079932