· Machine Learning · 2 min read
📋 Prerequisites
- Basic understanding of machine learning concepts
🎯 What You'll Learn
- Understand what underfitting is and why it occurs
- Learn to detect underfitting in your models
- Explore strategies to fix underfitting
- Build models that learn effectively without underfitting
Introduction
Underfitting is a situation in machine learning where a model is too simple to capture the underlying patterns in the training data.
It leads to:
✅ Poor performance on the training set.
✅ Poor performance on the test set.
1️⃣ What is Underfitting?
Underfitting occurs when:
✅ A model fails to learn the relationships in the training data.
✅ The model is too simplistic for the complexity of the task.
Example: Using a linear model for a dataset with a clear nonlinear relationship.
2️⃣ Why Does Underfitting Occur?
✅ Model is too simple: Insufficient complexity to capture patterns.
✅ Insufficient training: Not enough epochs or iterations.
✅ Over-regularization: Too much regularization can oversimplify the model.
✅ Irrelevant or insufficient features: Using poor-quality data.
3️⃣ How to Detect Underfitting
✅ High bias: Both training and test errors are high.
✅ No improvement with training: Loss remains high even as training progresses.
✅ Visualization: The model does not capture trends in data plots.
4️⃣ Strategies to Fix Underfitting
a) Increase Model Complexity
Use more complex models (e.g., deeper neural networks, higher-degree polynomials).
b) Train Longer
Increase the number of epochs or iterations to allow the model to learn better.
c) Reduce Regularization
Decrease L1/L2 regularization strength to allow the model to learn more.
d) Feature Engineering
✅ Add relevant features.
✅ Remove irrelevant features.
✅ Use feature extraction methods to capture better signals.
5️⃣ Example in Python
from sklearn.linear_model import LinearRegression, PolynomialFeatures
from sklearn.pipeline import make_pipeline
# Example: Using polynomial regression to increase model complexity
degree = 3 # Increase degree to capture nonlinear patterns
model = make_pipeline(PolynomialFeatures(degree), LinearRegression())
model.fit(X_train, y_train)
Conclusion
✅ Underfitting occurs when your model is too simple to capture patterns in data.
✅ It can be addressed by increasing model complexity, training longer, reducing regularization, and using better features.
By understanding underfitting, you can build balanced models that learn effectively and generalize well.
What’s Next?
✅ Compare underfitting vs overfitting to understand the bias-variance trade-off.
✅ Experiment with tuning your models to find the right complexity.
✅ Continue your structured machine learning journey on superml.org
.
Join the SuperML Community to discuss your model tuning experiences and learn collaboratively.
Happy Learning! 📈