๐ Course contents
AI & Computer Vision, lesson 19 of 52
Evaluation: The Metrics That Matter
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 ball | Model said no ball | |
|---|---|---|
| There was a ball | True positive (TP): caught it | False negative (FN): missed it |
| There was no ball | False positive (FP): false alarm | True negative (TN): correctly quiet |
Every metric below is made from these four numbers.
The metrics
| Metric | Formula | Plain question |
|---|---|---|
| Accuracy | (TP + TN) / everything | How often is it right overall? |
| Precision | TP / (TP + FP) | When it says "ball", how often is it right? |
| Recall | TP / (TP + FN) | Of the real balls, how many did it find? |
| F1 | 2 ร 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?)
| Threshold | Effect |
|---|---|
| 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
| Job | Worse mistake | Favour |
|---|---|---|
| Auto-highlight reel: find goals (lesson 42) | Missing a goal | Recall |
| Auto-trigger a light when a player enters a zone (lesson 35) | Triggering on a shadow | Precision |
| Counting passes for stats | Both matter | F1 |
| Safety stop on a robot arm | Missing a person | Recall, 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.

