๐Ÿ“š Course contents

AI & Computer Vision, lesson 19 of 52

Evaluation: The Metrics That Matter

intermediate23 min readFull course

Introduction

Your model says it's 95% accurate. Is it any good? Maybe not: if 95% of your crops have no ball, a model that always says "no ball" scores 95% too. Today you'll learn the numbers professionals use instead (precision, recall and F1), see how one setting trades them against each other, and finally open the sealed test folder.

By the end of this lesson you'll be able to:

  • Show with an example why accuracy alone can lie
  • Fill in a confusion matrix (true positives, false positives, false negatives, true negatives)
  • Calculate and explain precision, recall and F1
  • Explain how the threshold trades precision against recall
  • Choose which metric matters for a given job
  • Score a model on the test folder, once, and write up the result

Working principle

Why accuracy lies

If only 5% of your crops contain a ball, a model that always says "no ball" is 95% accurate and finds no balls at all. Accuracy counts all mistakes the same and hides what the model is bad at.

The confusion matrix: four boxes

Model said ballModel said no ball
There was a ballTrue positive (TP): caught itFalse negative (FN): missed it
There was no ballFalse positive (FP): false alarmTrue negative (TN): correctly quiet

Every metric below is made from these four numbers.

The metrics

MetricFormulaPlain question
Accuracy(TP + TN) / everythingHow often is it right overall?
PrecisionTP / (TP + FP)When it says "ball", how often is it right?
RecallTP / (TP + FN)Of the real balls, how many did it find?
F12 ร— precision ร— recall / (precision + recall)One number that is low if either one is low

The threshold

The model outputs a probability. We call it "ball" if the probability is above a threshold, 0.5 by default.

Caught 14, missed 6, false alarms 5, correct "no ball" 25. Precision 74% (when it says ball, is it right?) ยท Recall 70% (of the real balls, how many found?)

ThresholdEffect
Lower (0.3)More balls found (recall up), more false alarms (precision down)
Higher (0.7)Fewer false alarms (precision up), more missed balls (recall down)

There is no best threshold in general. It depends on the job.

Which metric matters? Ask what a mistake costs

JobWorse mistakeFavour
Auto-highlight reel: find goals (lesson 42)Missing a goalRecall
Auto-trigger a light when a player enters a zone (lesson 35)Triggering on a shadowPrecision
Counting passes for statsBoth matterF1
Safety stop on a robot armMissing a personRecall, by a lot

Using the test set properly

  • Open the test folder once, after you have finished choosing the model and the threshold on the validation data.
  • If you change anything because of the test result, the test set is spent. Collect new data for a fair test.
  • Report the test result honestly, even if it's worse than validation.
Evaluation: The Metrics That Matter | Electronics Simplified