Coding Hubs School of AI – Best AI & Full Stack Courses in Delhi NCR | 100% Placement
Limited Offer: Get 50% OFF on AI & Full Stack Courses
📞 Call Now: +91 8448811540
Back to Machine Learning Notes
Topic #1802

Underfitting

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.

SymptomOverfittingUnderfitting
Training performanceVery highPoor
Validation performanceNoticeably worse than trainingAlso poor, similar to training
Train/val gapLargeSmall

Common Causes

CauseWhy It Underfits
Model too simple for the true relationshipA linear model can't capture a genuinely curved pattern
Too much regularizationOver-penalizing complexity can suppress genuinely useful signal
Insufficient or poorly engineered featuresThe model never sees the information it would need
Training stopped too earlyThe 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?

Related ML Notes

Want to go beyond the notes?

Join Coding Hubs School of AI's Machine Learning course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available
💬 Talk to Advisor
1
WhatsApp

Latest from Our Blog

Insights on AI, Data Science, Full Stack & Career

View All Articles →