Generalization

Generalisation is a model's ability to perform well on new data it did not see during training, rather than only on the examples it learned from.

Training a model on examples is only useful if it then handles cases it has never met. Google's machine learning glossary defines generalisation as a model's ability to make correct predictions on new, previously unseen data, and calls it the opposite of overfitting. A spam filter that recognises only the exact spam messages it was trained on has not generalised; one that catches next week's new scams has.

Generalisation is measured by keeping some data back. A model is trained on a training set and then scored on a separate test set it never saw. The difference between its performance on the two is often called the generalisation gap. A small gap suggests the model learned patterns that carry over; a large one suggests it memorised its training examples. Techniques that encourage generalisation include more and more varied data, regularisation such as dropout, and early stopping.

Deep learning complicates the textbook picture. In a 2016 paper, published at the ICLR conference in 2017, Chiyuan Zhang, Samy Bengio, Moritz Hardt, Benjamin Recht and Oriol Vinyals showed that leading image classifiers could perfectly fit training data whose labels had been replaced at random, and even images replaced with pure noise. The same networks generalise well on real data, so their size and the usual explanations cannot by themselves account for when they generalise and when they memorise. Phenomena such as double descent and grokking are part of the same puzzle.

For AI news, generalisation is the question behind many headlines. A benchmark score shows generalisation only if the test questions were not in the training data; when they leak in, the score overstates what the model can do. A model can also generalise well to data like its training data and poorly to situations that differ from it, such as a medical model trained in one hospital and used in another.

In practice, ask of any impressive result: tested on what? Good performance on genuinely new, realistic cases is the thing that matters, and it is harder to show than a high score on familiar material.

Common questions

What is generalisation in machine learning?

It is how well a trained model performs on new data that was not part of its training. A model that generalises well has learned patterns that carry over to fresh cases rather than memorising its training examples.

What is the difference between overfitting and generalisation?

They are opposites. An overfitted model fits its training data so closely, noise included, that it does badly on new data. A model that generalises well performs nearly as well on new data as on its training data.

How is generalisation measured?

By testing the model on data held back from training, usually a test set, and comparing that performance with its performance on training data. The comparison is only fair if the test data truly never appeared in training.

Why do huge neural networks generalise at all?

This is still an open research question. A 2016 study showed that large image classifiers can memorise even randomly labelled data, yet the same networks generalise well on real data, which classic explanations based on model size do not fully account for.

Finding more

Search for "generalization in machine learning", "generalization gap" or "rethinking generalization" to read more. Google's Machine Learning Crash Course covers the basics; research papers on arXiv cover the open questions. When reading about benchmark results, look for information on how the test data was kept separate from training data, and treat results without it with caution.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.