| Metric | Formula | Meaning |
| Accuracy | TP + TNTotal instances | Proportion of correctly predicted instances among all instances |
| Precision | TPTP + FP | Correctly predicted positives out of all predicted positives |
| Recall (sensitivity) | TPTP + FN | Correctly predicted positives out of all actual positives |
| F1 score | 2 × Precision × RecallPrecision + Recall | Harmonic mean of precision and recall |
Why the harmonic mean: it corrects extreme values. If either precision or recall is very low, F1 is low even if the other is high. F1 is most useful when the data is imbalanced.
Class example Class
| Predicted 1 | Predicted 0 |
| Actual 1 | TP = 83 | FN = 17 |
| Actual 0 | FP = 13 | TN = 87 |
Precision = 8383 + 13 = 8396 = 0.8646 = 86.46%
Recall = 8383 + 17 = 83100 = 0.83 = 83%
Accuracy = 83 + 8783 + 17 + 13 + 87 = 170200 = 85%
F1 = 2 × 0.8646 × 0.830.8646 + 0.83 = 1.43521.6946 = 84.69%
Slide example
TP = 40, FN = 10, FP = 5, TN = 45, tested on 100 data points.
Accuracy = 40 + 45100 = 85% Precision = 4045 = 88.9% Recall = 4050 = 80%
F1 = 2 × 88.9 × 8088.9 + 80 = 84.2%
NoteThe slide prints F1 as 84.3%. The exact value is 80 ÷ 95 = 84.21%. Show your working in the exam.
Likely questionGiven a confusion matrix, calculate accuracy, precision, recall and F1 score.