分类问题中的相关指标

accuracy, precision, recall, F et al.

real = 1 real = 0
predict = 1(TP) predict = 1(FP)
predict = 0(FN) predict = 0(TN)
  • TP: true positive,正类预测正确
  • FN: false negative,正类预测错误
  • FP: false positive,负类预测错误
  • TN: true negative,负类预测正确

总的样本个数为:TP + FN + FP + TN

准确率(accuracy)

$${accuracy = \frac{TP + TN}{TP + FN + FP + TN}}$$

查准率或精度(precision)

$$ precision = \frac{TP}{TP + FP} $$

查全率或召回率(recall)

$$ recall = \frac{TP}{TP + FN} $$

如何理解Precision/Recall 假设100癌症训练集中,只有1例为癌症。如果模型永远预测y=0,则模型的Precision=99/100,很高。但Recall=0/1=0,非常低。 所以单纯用Precision来评价模型是不完整的,评价模型时必须用Precision/Recall两个值。

F1指标

综合了查准率(precision)和查全率(recall)的指标

$$ F1 = \frac{2 * precision * recall}{precision + recall} $$

上述四种指标常用于二分类问题,对于多分类问题,常有以下指标:

Macro Average

综合过后进行取平均值的计算, 包括:

Macro-accuracy
Macro-precision
Macro-recall
Macro-F1

$$ precision_i = \frac{TP}{TP + FP}, \ for \ i < number_{type} $$ $$ recall_i = \frac{TP}{TP + FN}, \ for \ i < number_{type} $$ $$ f_i = \frac{2 * precision * recall}{precision + reacll}, \ for \ i < number_{type} $$

最终的求解结果

$$ precision = \frac{\sum_i{precision_i}}{number_{type}} $$ $$ recall = \frac{\sum_i{recall_i}}{number_{type}} $$ $$ f = \frac{\sum_i{f_i}}{number_{type}} $$

Chuanbo Zhu
Chuanbo Zhu
PhD Candidate of Computer Science and Technology

My research interests include multimodal intelligence, sentiment analysis, emotion recognition and sarcasm detection