Skip to main content

Classification Metrics: Precision, Recall and F1

BeginnerQuantitative FinanceAlso known as: confusion matrix, machine learning in finance, accuracy, false positives, default prediction

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

Precision\displaystyle Precision=TPTP+FP,  Recall=TPTP+FN,  F1=2 P RP+R,  Accuracy=TP+TNTP+FP+FN+TN\displaystyle =\frac{TP}{TP+FP},\; Recall=\frac{TP}{TP+FN},\; F_{1}=\frac{2\,P\,R}{P+R},\; Accuracy=\frac{TP+TN}{TP+FP+FN+TN}

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

TPTrue positives: flagged and correctcount
FPFalse positives: flagged but wrongcount
FNFalse negatives: missedcount
TNTrue negatives: not flagged and correctcount

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%
Precision45 ÷ (45 + 15)75%
Recall45 ÷ (45 + 5)90%
F12 × 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%
The answer

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.

Want every formula on a few pages?Get the free Cheat Sheet (PDF) →

Calculator

Accuracy98%
Precision75%
Recall90%
F181.82%

Keep going