最重要分清四個變量:
https://en.wikipedia.org/wiki/Sensitivity_and_specificity
- True positive (TP): e.g., Sick people correctly identified as sick
- False positive (FP): e.g., Healthy people incorrectly identified as sick
- True negative (TN): e.g., Healthy people correctly identified as healthy
- False negative (FN): e.g., Sick people incorrectly identified as healthy
In general, Positive = identified and negative = rejected. Therefore:
- True positive = correctly identified
- False positive = incorrectly identified
- True negative = correctly rejected
- False negative = incorrectly rejected
所以:
condition positive (P):the number of real positive cases in the data
condition negative (N):the number of real negative cases in the data
即 P = TP + FN, F = TN + FP
準確率 Accuracy = (TP + TN) / (P + N) = (TP + TN) / (TP + FN + TN + FP)
精確率Precision = TP / (TP + FP)
召回率Recall = TP / P = TP / (TP + FN)
F1-Score = 2 * (Precision * Recall) / (Precision + Recall) = 2 * TP / (2 * TP + FP +FN)
示例說明:
1000個病人,現被確診400個病人,600個健康人。
這400個病人實際上有300個病人(TP)和100給誤判的健康人(FP);
而這判定爲健康的600人中,有500個是健康人(TN),100個病人(FN)。
即: TP = 300, FP = 100, TN = 500, FN = 100.
注:實際上的患者爲500人(P = TP + FN),500個健康人(F = TN + FP)
所以:
準確率Accuray = (TP + TN) / (TP + FN + TN + FP) = 800 / 1000 = 80%
精確率Precision = TP / (TP + FP) = 300 / (300 + 100)= 75%
召回率Recall = TP / (TP + FN) = 300 / (300 + 100) = 75%
F1-score = 2 * (Precision * Recall) / (Precision + Recall) = 75%