How Models Learn, and What "95% Accurate" Means
You'll be able to:
You can explain training and test sets and overfitting, and work out from a base rate how many of a model's alarms are real.
A clinic buys a screening tool advertised as 95% accurate. A patient is flagged. How likely is it that the patient has the condition? Most people answer "about 95%". If one person in a hundred has the condition, the real answer is about 16%. This lesson explains how a model learns and why its headline number so often misleads.
Learning from examples
A predictive model learns from labelled examples: thousands of emails marked spam or not spam, or thousands of scans marked healthy or not. It starts with random numbers. It makes a guess for one example, the guess is compared with the label, and its numbers are nudged so the guess would have been slightly better. After millions of rounds the numbers capture whatever pattern separates the examples.
"Whatever pattern" is the catch. The model has no idea which differences matter to you. In a well-known 2016 demonstration, researchers trained a classifier to tell wolves from huskies, using photos they had chosen so that every wolf stood in snow. It learned to look for snow and not for the animal, and only an explanation tool made that visible. A model learns the easiest pattern that works on its examples, and that is not always the one you meant.
Training set, test set, overfitting
To find out whether a model learned something general, builders hold back some examples and never show them during training. The held-back group is the test set. A model that does well on its training examples and badly on the test set has memorised the examples. This is called overfitting.
A test score has a limit of its own. It tells you how the model does on cases like the test set. A model trained and tested on scans from one hospital can drop sharply at another hospital with different machines. The test was honest. The world was different.
Worked example: what "95% accurate" means
Take 10,000 people. One in a hundred has the condition.
- 100 people have it. The tool finds 95% of them: 95 correct alarms.
- 9,900 people do not have it. The tool wrongly flags 5% of them: 495 false alarms.
- In all, 95 + 495 = 590 people are flagged, and 95 ÷ 590 = 16% of them have the condition.
The tool is not broken. The condition is rare, so the healthy group is a hundred times larger, and a small error rate on a large group gives more false alarms than there are real cases.
Change the three numbers and watch the share of real alarms move:
Lab
How many alarms are real?
| People tested: 10,000 | Flagged | Not flagged |
|---|---|---|
| Have it 100 | 95 | 5 |
| Do not have it 9,900 | 495 | 9,405 |
Of the 590 people flagged, 16% have the condition.
The tool is right for 95% of everyone tested.
Try a question
10,000 people are tested. 5% have the condition. The tool finds 80% of real cases and wrongly flags 5% of the people who do not have it. Of the people it flags, what percentage have the condition?
The numbers change each time. The answer is computed by the lab.
Runs in your browser. Nothing is sent or saved.
The same arithmetic produces a second trap. If one transaction in a thousand is fraud, a model that says "not fraud" every time is 99.9% accurate and useless.
So when you see one accuracy figure, ask three things:
- Of the real cases, how many does it find?
- Of the cases it flags, how many are real?
- What data was it tested on, and does that data look like mine?
Try it now (10 minutes)
Open Teachable Machine, a free tool that trains a small image model in your browser. Train it to tell two objects apart, for example a mug and a phone, with about thirty webcam images of each. Test it. Then hold the mug in front of a different background, or in your other hand. Note what breaks it. You have just reproduced the wolf-and-snow problem.
Where people go wrong
- Reading accuracy as "chance that this alarm is right". These are different numbers, and for rare events they are far apart.
- Trusting a test score without asking what the test set was. A score from someone else's data is a claim about someone else's data.
- Assuming the model learned the concept. It learned a pattern that separated the examples. Check what it does when the background changes.
What to remember
- A model learns the easiest pattern that separates its examples, whether or not it is the right one.
- Good on training data and bad on held-back data means it memorised.
- A test score holds only for cases like the test set.
- For rare events, ask how many real cases are found and how many alarms are real. A single accuracy figure hides both.
Curated Materials
1hThe deep work happens here — the lesson is your briefing.
Live on aiqbench
This lesson's subject on the rest of the site, today.
In the news, last 30 days
- Build a PDF Chatbot for Your Website with Gradio and Hugging Face ZeroGPUTowards Data Science ·
- From chatbots to AI agents: Banco Guayaquil’s next chapter in bankingSiliconANGLE ·
- When Does Fine-Tuning Overtake Prompting? An Accuracy and Cost Analysis of Small Language Models on Narrow TasksarXiv ·
Test your knowledge
5 questions in 100 seconds, on a page of its own. Read everything above first.
Test your knowledge →Module Mission
25–30 minIn Teachable Machine, train a model to tell two objects apart with about 30 images each. Test it on 10 new images and record the score. Then find three inputs it gets wrong and write what you think it learned.
Good looks like
- A score out of 10 on new images, none of which were used for training.
- Three inputs the model got wrong, each described so someone else could repeat it.
- For each failure, a one-line guess at the pattern the model used instead of the object.
- One sentence on which extra images would fix it.
Loading your work…