No history yet

Model Selection Trade-offs

Understanding Model Error

When we build a machine learning model, our goal isn't just to make accurate predictions on the data we used for training. We want the model to generalize—to perform well on new, unseen data. The total error of any model can be broken down, helping us understand why it might not be generalizing as well as we'd hope.

The bias-variance trade-off is a fundamental concept in machine learning that describes the trade-off between two sources of error that affect the performance of predictive models: bias and variance.

Essentially, a model's total expected error on unseen data is a combination of three distinct components: bias, variance, and irreducible error. Let's look at the equation that ties them together.

Error(x)=(Bias[f(x)])2+Variance[f(x)]+σ2\text{Error}(x) = (\text{Bias}[f'(x)])^2 + \text{Variance}[f'(x)] + \sigma^2

Think of bias as a model's stubbornness. A model with high bias, like a simple linear regression applied to a complex, non-linear problem, makes strong assumptions about the data. It might assume the relationship is a straight line when it's actually a curve. This leads to —the model is too simple to capture the underlying patterns, resulting in high error on both training and test data.

Variance, on the other hand, is like a model's gullibility. A model with high variance, such as a very deep decision tree, is extremely flexible. It can learn the training data so perfectly that it even models the random noise. This leads to —the model fits the training data exceptionally well but fails to generalize to new data, because it learned the noise, not just the signal.

Finding the Sweet Spot

The relationship between bias and variance is a zero-sum game. Decreasing one typically increases the other. This is the bias-variance trade-off. Simple models have high bias and low variance. Complex models have low bias and high variance.

Lesson image

Our goal is to find the sweet spot: the level of model complexity where the total error is minimized. This is the point where the increase in variance is balanced by the decrease in bias.

What About Irreducible Error?

There's one part of the error we can't do anything about: This is the inherent randomness or noise in a dataset that's beyond the control of any model. It represents the lower bound on the error we can ever hope to achieve.

For example, if you're trying to predict a person's weight based on their height, there will always be some error. People with the same height have different weights due to genetics, diet, and lifestyle—factors that might not be in your dataset. This natural variability is the irreducible error.

Now that you have a sense of the trade-offs involved in model selection, let's test your knowledge.

Quiz Questions 1/5

A machine learning model with high bias is likely to...

Quiz Questions 2/5

High variance in a machine learning model is a sign of...