Skip to content
ReEnvision
← Unit 3: How models learn

Training, overfitting and measuring success

How feedback turns a random model into a useful one, how learning can go too far, and how to judge the result.

Lesson 3.4 55 minNo coding required

Objectives

By the end of this lesson, you will be able to:

  • Describe training as a loop of guessing, measuring error and adjusting
  • Explain overfitting and how a test set reveals it
  • Explain why accuracy alone can mislead, using false positives and false negatives

Key terms

Loss
A number that measures how wrong a model's answers are. Training tries to make it smaller.
Overfitting
When a model memorizes its training examples, including their quirks, and performs poorly on new ones.
False positive
The model says yes when the true answer is no.
False negative
The model says no when the true answer is yes.

Reading

The training loop

Training repeats four steps. The model makes a guess on some examples. We compare its guesses with the correct answers and compute a number, the loss, that says how wrong it was. An algorithm works out which way to nudge each weight to shrink the loss. The weights are nudged slightly. Then the loop repeats, often millions of times.

Picture walking down a hill in thick fog. You cannot see the bottom, but you can feel which way the ground slopes under your feet. Take a small step downhill, feel again, step again. Training is that walk, where height is the loss.

Overfitting: learning too much

Push training too far on too little data, and a model starts memorizing its training examples, including their accidents and noise. Its training score climbs toward perfect while its performance on new examples gets worse. This is overfitting.

It is the student who memorized last year's answer sheet. The hidden test set from Unit 2 is how we catch it: a wide gap between the training score and the test score is the warning sign. The usual remedies are more varied data, a simpler model, or stopping training earlier.

Accuracy is not the whole story

Accuracy is the share of answers a model gets right. It sounds like all you need, and it can badly mislead. Suppose a condition affects 1 person in 100. A model that says "no" to everyone is 99% accurate and completely useless.

So we look at the kinds of mistakes. A false positive is a false alarm: a spam filter that hides a real email. A false negative is a miss: a spam filter that lets spam through. Which is worse depends on the situation. For a medical screening test, a miss may be far more serious than a false alarm that leads to a follow-up check.

Choosing which mistake to tolerate is a decision about values, and people must make it. The model cannot.

Try it · Interactive lab

Set the spam cut-off

A spam detector has scored 20 messages. You decide the cut-off. Drag the slider and watch the two kinds of mistake trade off.

0 · looks safelooks like spam · 10

Spam Real mail Mistake

Spam caught
7
Real mail kept
8
False alarmsreal mail hidden
3
Missesspam let through
2
Accuracy
75%

Try this: find the cut-off with zero false alarms, then the one with zero misses. Can any single cut-off give you both?

Build it in the AI StudioThe Careful AIUse the AI's confidence score to make it say "I'm not sure" instead of guessing.

Group activity 25 min

Tune the detector

You will need

  • 20 cards, each with a number from 1 to 10 (a "suspicion score") and a hidden true label on the back (15 Safe, 5 Problem), arranged so that scores overlap between the two labels
  • A table for counting correct answers, false positives and false negatives
  1. 1

    Lay the cards out in order of suspicion score, labels hidden.

  2. 2

    Choose a threshold: every card above it will be flagged as a Problem. Flip the cards and count correct answers, false positives and false negatives.

  3. 3

    Move the threshold lower and count again. Move it higher and count again.

  4. 4

    Decide which threshold you would use if the detector were (a) a spam filter and (b) a smoke alarm. Explain why your answers differ.

Discuss

  1. Q1

    No threshold removed both kinds of mistake. Why not?

  2. Q2

    For a system that flags possible cheating on exams, which mistake is worse? Who bears the cost of each?

  3. Q3

    A company announces its model is "99% accurate." What two questions would you ask?

Write your answer to one of the questions. Saved only on this device.

Quick check

Choose an answer to see whether you were right, and why.

  1. 1What does the loss measure during training?

  2. 2A model scores 99% on its training data and 65% on the test set. What is the likely problem?

  3. 3A smoke alarm fails to sound during a real fire. This is a:

Key takeaways

  • Training is a loop: guess, measure the error, adjust, repeat.
  • Overfitting is memorizing instead of learning; a test set exposes it.
  • Look past accuracy to the kinds of mistakes, and decide which matter most.