Underfitting is overfitting's opposite failure mode — a model too simple to capture the real pattern in the data, performing poorly on training data and new data alike.
The Clearest Signal
Unlike overfitting's large train/validation gap, underfitting shows both scores being poor and close together — the model isn't failing to generalize a pattern it learned; it never learned an adequate pattern to begin with.
| Symptom | Overfitting | Underfitting |
|---|---|---|
| Training performance | Very high | Poor |
| Validation performance | Noticeably worse than training | Also poor, similar to training |
| Train/val gap | Large | Small |
Common Causes
| Cause | Why It Underfits |
|---|---|
| Model too simple for the true relationship | A linear model can't capture a genuinely curved pattern |
| Too much regularization | Over-penalizing complexity can suppress genuinely useful signal |
| Insufficient or poorly engineered features | The model never sees the information it would need |
| Training stopped too early | The model hasn't had enough iterations to fit even the real pattern |
Diagnosing It in Code
from sklearn.linear_model import LinearRegression
from sklearn.metrics import r2_score
model = LinearRegression().fit(X_train, y_train)
train_r2 = r2_score(y_train, model.predict(X_train))
val_r2 = r2_score(y_val, model.predict(X_val))
print(f"Train R²: {train_r2:.3f}, Validation R²: {val_r2:.3f}")
# Both low and close together (e.g. 0.35 and 0.33) -> underfitting,
# not the large-gap pattern that signals overfitting
The Fixes
- Use a more flexible model (e.g. polynomial features, a tree-based model instead of linear)
- Reduce regularization strength, if it was set too aggressively
- Add more, or better-engineered, features — see Feature Engineering
- Train longer / increase model capacity, for iterative or capacity-limited models
Practical Use Cases
Underfitting is the useful check to run when a model performs surprisingly poorly on everything, not just on new data — it points squarely at model capacity or feature quality, not generalization technique.
Common Mistakes
- Applying overfitting fixes (more regularization, simpler model) to a genuinely underfitting model — this makes underfitting worse.
- Assuming a simple model is always "safer" — an overly simple model is just a different, equally real failure mode.
Interview Relevance
Q: "Your model has 60% training accuracy and 58% validation accuracy. Is this overfitting?" No — both scores are poor and close together, the signature of underfitting, not overfitting; the fix here is more model capacity or better features, not more regularization or early stopping.
Practice Question
A linear regression model shows R²=0.3 on both training and validation data for a target you suspect has a genuinely curved relationship with the features. What would you try first?