Skip to content
IT glossary
Data and MLUpdated December 3, 2026

Overfitting

Переобучение

A model overfits when it learns details specific to its training examples that do not hold up on new, similar data. It can score well during training and still make poor predictions on unseen examples.

Also known as: недообучение, underfitting

What overfitting looks like

Imagine training a model to predict house prices. Floor area and location are useful predictors, but a flexible model might also learn a rule based on a few unusually expensive homes in one training sample. That rule reduces training error without making the model better at pricing the next house. Overfitting is about learning patterns that don't generalize; it doesn't require literally memorizing the dataset.

Underfitting is a different problem. An underfit model fails to capture useful patterns even in the training data. If both training and validation performance are poor relative to a reasonable baseline, try improving the features or giving the model more flexibility before assuming it needs more regularization.

How to spot it

Compare the same metric on the training set and on validation data that represent the intended use. A model that does well on training data but substantially worse on validation data may be overfitting. For models trained over multiple epochs or boosting rounds, look at the loss curves: falling training loss alongside steadily rising validation loss is a signal that continued training is hurting generalization.

A performance gap is not proof. If the validation set covers a new market, changes in the data may explain the drop. The reverse can happen too: near-duplicates across splits can make validation performance look better than it really is. Fit preprocessing steps on training data only, and choose a split that reflects the job the model will do: for a forecast, validate on later observations rather than randomly mixing past and future.

Example: choosing a tree depth

Suppose a deep decision tree predicts sale prices with a mean absolute error of $4,000 on training data and $32,000 on validation data. A shallower tree trained and evaluated on the same split gets $19,000 and $24,000, respectively. The shallow tree fits the training examples less closely, but it is the better candidate because its validation error is lower, not because the gap is smaller. After choosing the depth, use a test set that played no role in the choice to estimate final performance.

How to reduce it and discuss it in interviews

Match the fix to the model. Cap tree depth or require more examples per leaf; add a penalty on large coefficients in a regression model; or use early stopping to keep the checkpoint with the best validation score. More training data can help if it represents the cases the model will face. Use cross-validation when data are limited and a single validation split is too noisy, with folds that respect any time ordering or groups.

In an interview, don't jump from “high training score, low validation score” straight to “add regularization.” Explain how you'd check the split and rule out leakage, what simpler baseline you'd compare against, and which held-out metric would tell you that the change helped.