Machine learning with football · Chapter 4 · Classification

Accuracy, precision and recall

Five numbers from the same four boxes, and each one answers a different question.

Estimated time: 15 minutes · page 3 of 7

Five questions, five numbers

The four boxes are counts. These metrics turn them into rates, each one at the threshold you set on the board. Move the threshold and they all change.

MetricFormulaThe question it answers
Accuracy(TP + TN) / allHow many matches did it get right?
Recall (true positive rate)TP / (TP + FN)Of the real home wins, how many did it catch?
False positive rateFP / (FP + TN)Of the matches without a home win, how many did it wrongly call one?
PrecisionTP / (TP + FP)Of the home wins it called, how many happened?
F1 score2TP / (2TP + FP + FN)Precision and recall in one number, close to the worse of the two

Accuracy is the obvious one and the most misleading. Picture a model for red cards, which happen in maybe one match in ten. A model that always says "no red card" is 90% accurate and completely useless. On imbalanced data, look at recall and precision instead.

Precision and recall pull against each other. Raise the threshold and the home wins you do call are more likely right, so precision goes up, but you miss more of them and recall drops. Try it on the board. When a denominator is 0, say nothing is called a home win, the metric is undefined and shows n/a.

Check yourself

A model has 5 true positives, 6 true negatives, 3 false positives and 2 false negatives. What is its recall?
Another model: 3 true positives, 4 true negatives, 2 false positives, 1 false negative. What is its precision?
A tipster backs every predicted home win and loses the stake on every wrong one. A missed home win costs nothing. Which metric should the threshold aim for?
A scouting model flags young players worth a visit. Missing a future star is expensive, an extra trip is cheap. Which metric matters most?

Which one to watch

  • Accuracy for a rough first look on balanced data, never alone and never on imbalanced data.
  • Recall when a false negative costs more than a false positive.
  • False positive rate when a false positive costs more than a false negative.
  • Precision when the positive calls themselves have to be right.

Very small counts make these jumpy. With four matches without a home win, one false alarm is an FPR of 25% and two make it 50%.

Terms on this page: Accuracy, F1 score, False positive rate (FPR), Precision, Recall (true positive rate)

Leagues