esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
Let’s talk

I’ll build the agent for it.

What Is Early Stopping?

What early stopping is, how a held-back score and patience decide when to stop training, and why you keep the best checkpoint, for your AI interview.

In short

Early stopping means ending training once the score on held-back data stops improving, instead of running every planned round. You keep the version that scored best, and it also limits overfitting, where a model memorises its training data.

10 min readBeginnerCommon · estimateFacts checked 27 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

Early stopping is a way to decide when to stop training a model. I hold back some data the model never trains on, and I score the model on it after every round. If that score stops improving for a set number of rounds, I stop, and I keep the version that scored best, even if it came before the last round. It is a simple guard against a model that memorises its training data. It needs a held-back set, and a patience setting that is not too short.

What is early stopping, in plain words?

Early stopping means you stop training a model at the point where it stops getting better on data it has not learnt from, instead of running every planned round. The held-back data is never used for training, so it shows whether the model really learnt the pattern.

Think of a fraud analyst who writes a new rule each week and checks it against last month's cases. When the catch rate stops rising for three weeks running, she stops tuning and goes back to the rule that caught the most fraud. A card company's fraud model works the same way. It is scored on held-back transactions after every round, and training stops when that score stops improving.

Key words

Epoch
One full pass through the training data.
Validation set
Examples held back from training, used only to score the model.
Patience
How many rounds in a row to wait for a real gain before stopping.
Checkpoint
A saved copy of the model at one point in training.

How does the stopping rule work?

  1. 1

    Hold back some data

    Set aside a validation set before training starts. The model never learns from it.

  2. 2

    Score after each epoch

    After every pass, measure the loss on the validation set. Loss is a number for how wrong the model is, so lower is better.

  3. 3

    Save when it really improves

    If the loss drops below the best so far by a clear margin, save a checkpoint and reset the wait count to zero.

  4. 4

    Count the misses

    If it does not beat the best, add one to the wait count.

  5. 5

    Stop and keep the best

    When the wait count reaches the patience limit, stop training and load the best checkpoint.

Watching the validation score

Training data

the model learns from these

Validation data

held back, scored after each epoch

Model

learns, then gets a fresh score

Watch the score

Score improved?

tiny gains count as noise

Wait count

+1 per epoch with no gain

Stop and restore best

the best checkpoint is the one kept

  1. 1Training examples are what the model learns from.
  2. 2Held-back examples only score the model, they never teach it.
  3. 3The score after this epoch is checked against the best so far.
  4. 4A real gain resets the count. No gain adds one.
  5. 5When the count hits the limit, training stops and the best version is kept.
Training data teaches the model, and validation data only scores it. After each epoch, a real gain resets the wait count, and a run of misses stops training and keeps the best checkpoint.

The margin matters. Validation scores bounce about from one round to the next, so a gain counts only when it is bigger than a small minimum. Scikit-learn calls that minimum gain tol, and the patience n_iter_no_change. Its rule is quoted below.

Why does it help, and what does it cost?

Early stopping is a way to stop a model overfitting. Google's machine learning glossary describes it as a method for regularization, though not a formal one, and scikit-learn writes out the patience rule:

  • “A method for regularization that involves ending training before training loss finishes decreasing.”

    Google machine learning glossary

  • “In early stopping, you intentionally stop training the model when the loss on a validation dataset starts to increase; that is, when generalization performance worsens.”

    Google machine learning glossary

  • “terminate training when validation score is not improving by at least tol for n_iter_no_change consecutive epochs”

    Scikit-learn, MLPClassifier

The same glossary adds that early stopping is not a formal regularization method, but it can effectively limit overfitting. A model trained for too long learns the quirks of its training data, and the held-back score is what catches that.

The cost has two sides. First, you give up some training data to validation. When Scikit-learn's neural network turns early stopping on, it holds back 10% of the training data by default (validation_fraction=0.1). Second, a patience that is too short can stop a model that would have improved after a noisy patch.

Two endings for the same run

Train to the end

Run all 12 epochs

no stop, so the run keeps going

Early stopping

Stop after epoch 9

patience 3, best kept at epoch 6

Last epoch kept

loss 0.36, best was 0.34

Best checkpoint kept

epoch 6, loss 0.34

  1. 1The run goes on to epoch 12 and keeps that model.
  2. 2Training stops at epoch 9, and the epoch 6 model is kept.
The same made-up run, two endings. Running to the last epoch keeps a model that scores worse on validation than the epoch 6 checkpoint that early stopping keeps.

What does the stop rule look like in code?

Here is the rule in plain Python. The validation losses are made up, one per epoch, and the code prints where it stops and which checkpoint it keeps.

Python
# A made-up fraud model: validation loss after each epoch (lower is better).
val_loss = [0.62, 0.48, 0.41, 0.37, 0.35, 0.34, 0.345, 0.343, 0.346, 0.349, 0.35, 0.36]
PATIENCE = 3       # epochs in a row without a gain before we stop
MIN_DELTA = 0.001  # smaller gains are treated as noise

best, best_epoch, waited = float("inf"), 0, 0
for epoch, loss in enumerate(val_loss, start=1):
    if loss < best - MIN_DELTA:
        best, best_epoch, waited = loss, epoch, 0
    else:
        waited += 1
        if waited == PATIENCE:
            print(f"Stop after epoch {epoch}: no gain for {PATIENCE} epochs")
            break
print(f"Keep the checkpoint from epoch {best_epoch} (loss {best:.3f})")

Output

Stop after epoch 9: no gain for 3 epochs
Keep the checkpoint from epoch 6 (loss 0.340)

Tip

Keep the checkpoint and the stop point apart in your head. Training stopped at epoch 9, but the model you ship is the one from epoch 6.

Where do real tools use it?

  • Scikit-learn

    Its neural network can switch early stopping on, and then it sets aside part of the training data as the validation set for you. It is off by default.

  • Histogram gradient boosting

    Scikit-learn's histogram-based gradient boosting turns early stopping on by default once a training set has 10,000 samples or more, and then it uses the validation loss.

  • Hugging Face Trainer

    Its early stopping callback stops training when a chosen metric gets worse for a set number of evaluations. The patience default is 1, so set it higher on noisy runs. It needs load_best_model_at_end switched on, and it waits for the next save step if save steps and eval steps differ.

  • Fine-tuning a language model

    With load_best_model_at_end on, the Trainer uses loss as its default metric, so the callback can stop a fine-tuning run when that loss stops improving.

Tip

Turn on load_best_model_at_end, which needs an evaluation schedule set, and the Trainer loads the best checkpoint at the end for you. That is the same idea as restoring the epoch 6 model.

What does the interviewer want to hear?

A strong answer covers

  • A plain definition: stop training when a held-back score stops improving.
  • The validation set, kept apart from the training data and the test set.
  • Patience and a minimum gain, because validation scores are noisy.
  • Keeping the best checkpoint as the final model.
  • It limits overfitting, at the cost of some data and a risk of stopping too soon.
  • Where it shows up: model libraries and fine-tuning runs.

Common traps

  • Trap"Train until the training loss stops falling."

    BetterTraining loss can keep falling even while the model gets worse on new data. Stop on the held-back score.

  • Trap"Stop when the test score is at its best."

    BetterPicking the stop point with the test set spoils it as a final check. Use a validation set for the stop rule.

  • Trap"Just keep the last model."

    BetterThe last epoch is often not the best one. Restore the best checkpoint.

Can you spot the safe stop rule?

Spot the rule

Which stop rule is safe for a fraud model?

Quick check

Your patience is 3. The best validation score was at epoch 6, and epochs 7, 8 and 9 gave no gain. Which model do you keep?

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q413Overfitting vs underfitting?10 min
  2. Q414L1, L2 and dropout regularisation?13 min
  3. Q422Train/validation/test splits?11 min
  4. Q423What is cross-validation?13 min
  5. Q297How do you spot overfitting during fine-tuning?11 min
  6. Q436How do you tune hyperparameters?10 min

Last updated on 27 November 2026

Training a model on your own data?

I design and build AI products and agents, including the training and evaluation checks behind them. Book a short call and tell me what you are training and how you measure it.