How machines learn

Overfitting

Overfitting is when a model memorizes its training examples, including noise and quirks, so it performs well on them but poorly on new, unseen data.

A student who memorizes last year's exam answers word for word will ace that exact paper and fail a new one. That is overfitting. The model has learned the specific examples rather than the general pattern behind them. It looks brilliant during training and disappoints in the real world.

Overfitting happens when a model is very flexible and the training data is small or noisy. The model has enough capacity to fit every wrinkle, including random errors. The fix is to test on data held back from training, and to use techniques that push the model toward simpler explanations.

The opposite problem is underfitting, when the model is too simple to capture the pattern at all. Good machine learning is a balance between the two. Whenever someone quotes a model's score, ask whether it was measured on training data or on fresh data.

Example

A plant-identifying app trained only on photos from one sunny garden gets every one of those photos right, then fails on a leaf photographed indoors.

Guide: ML literacy for builders →