How do you spot overfitting?
An overfit model scores well on the training set and poorly on validation or test data [1]. Google shows what this looks like in loss curves: training loss keeps falling or levels off, while validation loss starts climbing after a certain number of iterations. In a well-fitted model, the two curves follow a similar shape [1]. IBM points to k-fold cross-validation as a popular check: the data is split into k equal folds, each fold takes a turn as the test set, and the scores are averaged [2].
Google's example is a classifier for diseased trees. A convoluted boundary separates the training trees almost perfectly, yet misclassifies many of the trees in the test set [1].
Why does it happen?
Google names two causes: training data that doesn't represent real-world data well enough, and a model that is too complex [1]. IBM adds that training for too long can lead a model to learn noise and irrelevant detail [2]. The opposite of overfitting is generalisation, the ability to predict well on data the model hasn't seen [1].
How can you prevent it?
IBM's list includes stopping training before the model learns the noise (early stopping), adding more clean, relevant data, regularisation that penalises large coefficients, and removing redundant features [2]. There is a balance to keep: stop too early or strip out too many features and you end up underfitting instead [2].