Overfitting and Underfitting
Overfitting and underfitting are the two typical failure states of machine learning models, and understanding them is a prerequisite for tuning a model well.
Overfitting: learning too rigidly
The model absorbs the noise and accidental features in the training data as if they were rules. The symptom is: very high accuracy on the training set, very poor accuracy on the test set.
Analogy: a student crams every answer in the workbook, then is stumped by a new set of questions.
How to fix it:
- Add more training data
- Data augmentation (image flipping, cropping, adding noise)
- Regularization (L1/L2 penalizing large weights)
- Dropout (randomly dropping neurons during training)
- Early stopping (stop when validation performance degrades)
- Simplify the model structure
Underfitting: learning too shallowly
The model is too simple and has not even captured the basic rules of the training data. The symptom is: low accuracy on both the training set and the test set.
Analogy: a student has not studied at all and can answer nothing.
How to fix it: increase model complexity, add features, train longer, reduce the strength of regularization.
How to tell them apart
Look at the performance gap between the training set and the validation set:
- Good training, poor validation: overfitting
- Poor training, poor validation: underfitting
- Both good and close: the model is appropriate
The counterpart in the large-model era
The counterpart is memorization versus generalization. If a model merely memorizes the training data, it fails on new problems, which is why evaluations deliberately use unseen questions.