A model is overfit if it works better on training data than it does on other data.

Overfitting can be avoided in several ways. The simplest way is to have a dataset that’s a better representation of what is seen in the real world.

A complimentary way we can avoid overfitting is to stop training after the model has learned general rules, but before the model is overfit. This requires detecting when we’re beginning to overfit our model, though. We can do this using a test dataset.

First, if test performance stops improving during training, we can stop; there’s no point in continuing. If we do continue, we can end up encouraging the model to learn details about the training dataset that aren’t in the test dataset, which is overfitting.

Secondly, we can use a test dataset after training. This gives us an indication of how well the final model will work when it sees “real-world” data it hasn’t seen before.

GO ONE LEVEL DEEPER

Recognize the generalization gap

Overfitting is not simply high training accuracy. It is the growing gap between performance on seen data and performance on representative unseen data.

Typical training pattern
01

Learning

Training and validation performance improve together.

02

Plateau

Validation performance stops improving while training continues.

03

Divergence

The model fits training-specific noise and the gap widens.

Keep in mind

  • Use validation data for early stopping and model selection.
  • Reduce complexity, add regularization, or collect more representative data.
  • Check for leakage before concluding that a model truly generalizes.