Machine Learning Fundamentals interview question · Most asked

What is overfitting, and how do you prevent it?

Definition Asked in Machine Learning Engineer interviews

Members can save this page, take notes and track progress. See membership · Sign in

Summary

Overfitting is when a model learns the noise and quirks of its training data instead of the general pattern, so it scores well in training but poorly on new data. Prevent it with more or better data, simpler models, regularisation, early stopping, cross-validation and honest evaluation on held-out data.

Longer Answer

Techniques:

  • Regularisation: L1/L2 penalties, dropout, weight decay; limits on tree depth or leaf size.
  • Early stopping on a validation set for iterative learners (gradient boosting, neural networks).
  • Data: more examples, augmentation, removing leaky or ID-like features.
  • Model choice: fewer parameters, ensembles (random forests average away variance).
  • Evaluation: cross-validation for model selection and a final untouched test set; tuning hyperparameters on the test set overfits to it too.

Key Points

  • Great training score, poor generalisation.
  • Regularise, stop early, simplify.
  • More data and fewer leaky features.
  • Never tune on the test set.

Explanation

What interviewers look for

Several concrete techniques and awareness that hyperparameter tuning can overfit the validation data.

More Machine Learning Fundamentals questions

← All Machine Learning Fundamentals questions

Last reviewed · By the ByteCamel team · How we write content

Was this page helpful?

Report a mistake