📚 Course contents
AI & Computer Vision, lesson 20 of 52
Overfitting & the Bad-Data Lab
Introduction
In Unit 3 you heard "garbage in, garbage out". Today you prove it with numbers. First you'll learn to spot a model that has memorised its training data. Then you'll deliberately damage a dataset (wrong labels, too few balls, blurry pictures), retrain, and measure exactly how much each kind of bad data costs.
By the end of this lesson you'll be able to:
- Tell overfitting from underfitting by reading a learning curve
- Use early stopping and dropout (and more data) to fight overfitting
- Sabotage a dataset in three ways (wrong labels, class imbalance, low resolution) and measure the damage
- Say which metric reveals each kind of damage
- Write a short evidence-based statement: "this much bad data costs this much accuracy"
- Link each result to a rule in their field brief (lesson 15)
Working principle
Overfitting and underfitting
| Underfitting | Good fit | Overfitting | |
|---|---|---|---|
| Training accuracy | Low | High | Very high |
| Validation or test accuracy | Low | High | Much lower than training |
| Cause | Model too simple, too little training, bad features | Balanced | Model too big for the data, too many epochs, too few images |
| Picture | Learned nothing useful | Learned the pattern | Learned the noise and the particular images |
The learning curve
Plot training accuracy and validation accuracy for each epoch. Early on both rise. If training keeps rising while validation flattens or falls, the model has begun memorising. The best moment to stop is where validation was highest.
Early on, both curves rise together: the model is genuinely learning. Epoch 0.
Fixes for overfitting
| Fix | Idea |
|---|---|
| More (varied) data | Hardest to memorise. Usually the best fix. |
| Augmentation (lesson 13) | More variety from the same photos |
| Early stopping | Stop at the best validation epoch |
| Dropout | Randomly switch off some neurons during training, so none can be relied on alone |
| A smaller model | Fewer weights to memorise with |
The three sabotages
| Sabotage | What we do | Expected damage | Which metric shows it |
|---|---|---|---|
| A. Wrong labels | Flip a share of the training labels | Accuracy falls, and past about half it is just noise | Accuracy and F1 both fall |
| B. Class imbalance | Keep only a handful of ball examples | The model learns to say "no ball" | Recall collapses while accuracy looks fine |
| C. Low resolution | Shrink the images and enlarge them back | Small details disappear | Depends on object size: small balls suffer first |
The golden rule of the lab
We sabotage only the training data. The test set stays clean. That's how we know the damage came from the training data and not from changing the exam.

