Classification Metrics: Precision, Recall and F1
Finds: how good a yes/no model really is when the event is rare.
When to use it: Use it to judge a model that sorts cases into classes, such as default or no default, or fraud or genuine. When the event is rare, accuracy misleads: a model that never flags anything can be 98% accurate. Precision tells you how many flags are real, recall how many real cases were caught, and F1 balances the two.
The formula
In words: Precision = TP / (TP + FP); Recall = TP / (TP + FN); F1 = 2 x Precision x Recall / (Precision + Recall); Accuracy = (TP + TN) / total
What each symbol means
| TP | True positives: flagged and correct | count |
| FP | False positives: flagged but wrong | count |
| FN | False negatives: missed | count |
| TN | True negatives: not flagged and correct | count |
Worked example
A default model scores 1,000 loans. It flags 60 as defaults and 45 of those do default. In total 50 loans default.
| Accuracy | (45 + 935) ÷ (45 + 15 + 5 + 935) | 98% |
| Precision | 45 ÷ (45 + 15) | 75% |
| Recall | 45 ÷ (45 + 5) | 90% |
| F1 | 2 × 0.75 × 0.9 ÷ (0.75 + 0.9) | 81.82% |
| Accuracy of a model that never flags anything | (15 + 935) ÷ (45 + 15 + 5 + 935) | 95% |
Accuracy is 98%, which looks excellent but is mostly the many good loans. Precision is 75% (of the flagged loans, this share defaulted) and recall is 90% (of the loans that defaulted, this share was caught). F1 is 81.82%. A model that flagged nothing would score 95% accuracy with zero recall.