Hello! Welcome to your next lesson in the "Model Evaluation and Improvement" module.
In our last session, we learned how to quantify a regression model's performance using metrics like Mean Squared Error (MSE) and R-squared. These metrics tell us how much error our model has. Today, we'll dive deeper and ask why our model has errors in the first place. Understanding the sources of error is one of the most fundamental skills in machine learning.
Your learning outcome for this lesson is to describe the concepts of bias, variance, underfitting, and overfitting. These ideas form the backbone of model diagnostics and will help you understand why a model might be performing poorly and what you can do to fix it. This is a core concept for the GATE exam.
1. A Picture of Prediction Errors: The Dartboard Analogy
Before we get into formal definitions, let's start with a simple analogy. Imagine you're throwing darts at a dartboard. The bullseye represents the true, correct value you want your model to predict. Each dart you throw is one prediction.

Let's break down the four scenarios shown in the image:
- Low Bias, Low Variance (Top-Left): Your darts are tightly clustered right at the bullseye. This is the ideal scenario. Your predictions are accurate and consistent.
- High Bias, Low Variance (Bottom-Left): Your darts are tightly clustered, but they consistently miss the bullseye in the same spot. Your model has a systematic error, but it's consistent.
- Low Bias, High Variance (Top-Right): Your darts are scattered all over the board, but their average position is the bullseye. Your model is correct on average, but individual predictions are unreliable and inconsistent.
- High Bias, High Variance (Bottom-Right): Your darts are scattered all over the board, and they are not even centered on the bullseye. This is the worst-case scenario. Your predictions are both inaccurate and inconsistent.
This analogy gives us a great starting point for understanding the two main sources of reducible error in machine learning: bias and variance.
Understanding the Bias-Variance Tradeoff: A Beginner's Guide
To solidify this intuition, let's read the introduction to a helpful article that explains this analogy.
Read the first two sections of the article, from the beginning down to just before the heading 'Error Due to Bias'. Focus on how the author connects the dartboard analogy to the machine learning concepts of underfitting and overfitting.
2. Understanding Bias and Underfitting
Bias is the error introduced by a model's simplifying assumptions. If a model is too simple, it can't capture the true, complex patterns in the data. This leads to high bias.
Think of trying to fit a straight line to data that has a curved relationship. No matter how you adjust the line, it will never be able to capture the curve. This inability to model the true relationship is bias.
A model with high bias is said to underfit the data.
- Symptom: An underfitting model performs poorly on the training data and also performs poorly on the test data. Its errors are high everywhere because it's simply not a good model for the data.
This first video gives a fantastic visual explanation of bias.
Machine Learning Fundamentals: Bias and Variance
Let's watch this classic video from StatQuest. It clearly illustrates bias using a simple model trying to predict mouse height from weight.
Watch from the beginning (00:00) to 02:27. Notice how the simple 'straight line' model (linear regression) is unable to capture the true curved relationship. This inability is what we call bias.
3. Understanding Variance and Overfitting
Variance is the error introduced because a model is overly sensitive to the specific data it was trained on. A model that is too complex might learn not just the underlying patterns (the "signal") but also the random fluctuations and noise in the training data. This leads to high variance.
This model might look perfect on the training data, but because it has essentially memorized the noise, it won't generalize well to new, unseen data.
A model with high variance is said to overfit the data.
- Symptom: An overfitting model performs exceptionally well on the training data (very low error) but performs poorly on the test data (high error). This large gap between training and test performance is the classic sign of overfitting.
Let's continue with the StatQuest video to see what high variance looks like.
Machine Learning Fundamentals: Bias and Variance
Now, let's see the opposite problem: a model that is too complex.
Watch from 02:27 to 05:49. Observe how the 'squiggly line' model fits the training data perfectly but does a terrible job on the test data. The video defines this phenomenon as 'overfitting'.
4. Diagnosing Underfitting and Overfitting
We can diagnose these issues by comparing the model's error on the training set versus the test set. The next video walks through a great example using polynomial regression, where increasing the model's complexity (the degree of the polynomial) takes us from underfitting to a good fit, and finally to overfitting.
Machine Learning-Bias And Variance In Depth Intuition| Overfitting Underfitting
This video by Krish Naik provides a very practical way to think about and identify these problems by looking at training and test accuracy (or error).
Watch the segment from 00:36 to 07:21. Focus on these key ideas: Underfitting (degree 1 polynomial): High error on training data, high error on test data. The video calls this 'high bias'. Overfitting (degree 4 polynomial): Very low error on training data, but high error on new test data. The video calls this 'low bias, high variance'. Good Fit (degree 2 polynomial): Low error on training data and low error on test data. This is the goal, described as 'low bias, low variance'.
This leads us to a simple, practical guide for diagnosis, which is also summarized well in the "Bias-Variance Tradeoff, Explained" article.
This summary from the Towards Data Science article provides a quick guide to diagnosing model performance. Underfitting shows high error on both sets. Overfitting shows a large gap between a low training error and a high test error. A good balance has the best overall test performance with a moderate gap.
Test your understanding!
You are trying to predict house prices. You train two different models:
- Model A: Training RMSE = 85,000; Test RMSE = 87,000.
- Model B: Training RMSE = 10,000; Test RMSE = 90,000.
- Which model is likely suffering from underfitting (high bias)? Why?
- Which model is likely suffering from overfitting (high variance)? Why?
Show answer
- Model A is likely underfitting. Its error is high on both the training and test sets (85k and 87k). This indicates the model is too simple and cannot capture the underlying patterns in the data.
- Model B is likely overfitting. There is a huge gap between its performance on the training data (very low error of 10k) and the test data (very high error of 90k). This suggests the model has memorized the training data, including its noise, and cannot generalize to new data.
5. The Bias-Variance Tradeoff
As you might have guessed, bias and variance are in a constant tug-of-war. This relationship is known as the Bias-Variance Tradeoff.
- Simple Models (like linear regression) tend to have high bias and low variance. They are stable but often inaccurate.
- Complex Models (like a high-degree polynomial or a deep decision tree) tend to have low bias and high variance. They are flexible and can be accurate, but they are also unstable and prone to overfitting.
Our goal as data scientists is not to eliminate bias or variance entirely, but to find a "sweet spot" in model complexity that minimizes the total error.

Decomposing the Total Error
Mathematically, the total expected error of a model (specifically, the Mean Squared Error) can be broken down into three components:
We've discussed bias and variance. But what is Irreducible Error?
It's the inherent randomness or "noise" in a dataset that cannot be predicted by any model, no matter how perfect. It comes from factors that are not measured or are fundamentally unpredictable (like random human behavior in a house sale). This error sets the ultimate limit on how well any model can perform.
Understanding the Bias-Variance Tradeoff: A Beginner's Guide
Let's read a final excerpt to formally define irreducible error and see the full picture of the tradeoff.
Read the sections 'Irreducible Error' and 'The Bias-Variance Tradeoff'. Pay close attention to the definition of irreducible error and the equation that combines all three error components.
Conclusion
In this lesson, you've learned about the fundamental sources of error in machine learning models. This is a critical diagnostic skill for building effective models and a frequent topic in exams like GATE.
Key Takeaways:
- Bias is error from a model being too simple (underfitting). It's diagnosed by high error on both training and test data.
- Variance is error from a model being too complex and sensitive to noise (overfitting). It's diagnosed by a large gap between low training error and high test error.
- The Bias-Variance Tradeoff describes the inverse relationship between bias and variance as model complexity changes.
- The goal of model tuning is to find the optimal complexity that minimizes the sum of bias and variance, achieving the lowest possible total error on unseen data.
- Irreducible Error is the baseline noise in the data that no model can eliminate.
Preview of the Next Lesson:
Now that we can diagnose overfitting, what can we do about it? In our next lesson, we will explore powerful techniques called L1 (Lasso) and L2 (Ridge) regularization, which are specifically designed to combat overfitting by penalizing model complexity.