📚 Course contents

AI & Computer Vision, lesson 20 of 52

Overfitting & the Bad-Data Lab

intermediate28 min readFull course

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

UnderfittingGood fitOverfitting
Training accuracyLowHighVery high
Validation or test accuracyLowHighMuch lower than training
CauseModel too simple, too little training, bad featuresBalancedModel too big for the data, too many epochs, too few images
PictureLearned nothing usefulLearned the patternLearned 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

FixIdea
More (varied) dataHardest to memorise. Usually the best fix.
Augmentation (lesson 13)More variety from the same photos
Early stoppingStop at the best validation epoch
DropoutRandomly switch off some neurons during training, so none can be relied on alone
A smaller modelFewer weights to memorise with

The three sabotages

SabotageWhat we doExpected damageWhich metric shows it
A. Wrong labelsFlip a share of the training labelsAccuracy falls, and past about half it is just noiseAccuracy and F1 both fall
B. Class imbalanceKeep only a handful of ball examplesThe model learns to say "no ball"Recall collapses while accuracy looks fine
C. Low resolutionShrink the images and enlarge them backSmall details disappearDepends 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.

Overfitting & the Bad-Data Lab | Electronics Simplified