What is overfitting, and how do you spot it?
Machine learning basics · Beginner 1
Short answer
Overfitting is when a model learns the training data too closely, including its noise, so it does well on training data but badly on new data. You spot it when training performance keeps improving while validation performance stops improving or gets worse.
Deeper answer
A model that memorises rather than generalises looks great in training and fails in use. The standard check is to hold out data the model never trains on and compare scores. A large gap between training and validation scores is the signal.
Common remedies are more and more varied data, a simpler model, regularisation, early stopping and data augmentation. The same idea appears with LLM apps: a prompt tuned on five examples can overfit to them, which is why you test prompts on a separate, varied set.
What a strong answer covers
- The model learns noise in the training data
- Good on training, bad on new data
- Spotted by a gap between training and validation scores
- Fixes: more data, simpler model, regularisation or early stopping
Answer it out loud in the mock interview about 1 min
Follow-ups to expect
- How does the idea of overfitting apply to prompt engineering?
- What is the opposite problem, and how does it look?
Common mistakes
- Judging a model only by its score on training data
- Thinking more training always helps
Learn it
- How would you tell whether a new model really performs better in an A/B test?
- Explain the bias-variance trade-off.
- What is the difference between a random forest and gradient boosting?
- How does k-means work, and how do you choose k?
- What is data leakage, and how do you prevent it?
- Give an example of feature engineering that made a model better.
- How do you know whether you have enough training data?
- How do you handle a heavily imbalanced classification problem, such as fraud detection?
- What is the difference between linear and logistic regression?
- How do you deal with missing values in a dataset?
- Walk me through an ML project you did, end to end.
- Explain precision and recall with an example.
- What do L1 and L2 regularisation do?
- What is the difference between supervised and unsupervised learning?
- Why do we split data into training, validation and test sets?
- What is the difference between training and inference?