Elena' s AI Blog

Bias-Variance Challenge

10 Nov 2023 (updated: 05 Oct 2026) / 23 minutes to read

Elena Daehnhardt

Midjourney, November 2023


TL;DR:
  • Balance bias-variance tradeoff: high bias (underfitting) needs more complexity, high variance (overfitting) needs regularisation. Use cross-validation to find optimal model complexity.

Previous: Part 24 β€” Audio Signal Processing with Python's Librosa

Next: Part 26 β€” How recommendation engines actually work (with Python code)

Introduction: The Bias-Variance Tradeoff in Machine Learning

In machine learning, we usually start from a simple baseline model and progressively adjust its complexity until we reach that spot with the best model performance. We play with the model to fine-tune its parameters and complexity in an iterative process described in my previous post, the Machine Learning Process, wherein I have posted this diagram.

Machine-learning process

We want our Machine Learning (ML) model to solve a particular problem, for instance, detecting spam in e-mail messages.

The model should be well-trained, however, generalisable to new data when new spam messages not existing in the training dataset are received. In short, the model has to be well-fitted.

ML models should be resilient to noisy data, work well on unseen data, and help make unbiased decisions. We want to achieve an optimal variance to make generalisable models work well with new data.

How can we do this? The bias-variance tradeoff is the balance between a model that is too simple (high bias, underfitting) and one that is too complex (high variance, overfitting); the goal is the complexity that minimises total error on unseen data. Let’s detail the most essential machine learning concepts, particularly the bias-variance challenge.

Bias, Variance, and Irreducible Error

Different machine learning algorithms seek to minimise the chosen loss function during training. The algorithm aims to find the model parameters (coefficients or weights) that minimise the error on the training data. Minimising this error helps ensure the model generalises well to unseen data and makes accurate predictions or classifications.

In general, algorithmic error is typically decomposed into three fundamental components, as formalised in The Elements of Statistical Learning (Hastie, Tibshirani & Friedman):

  • Bias squared (Bias^2)
  • Variance (Variance)
  • Irreducible error

Error = Bias^2 + Variance + Irreducible Error

Irreducible error, also known as irreducible uncertainty or irreducible noise, is a component of the total error in a predictive model that cannot be reduced or eliminated by improving the model itself. It represents the inherent unpredictability and randomness in the data or the underlying process being modelled. This error source is considered β€œirreducible” because it is beyond the control of the model, and no matter how complex or sophisticated the model is, it cannot account for or reduce this source of error.

Irreducible error arises from various factors, including:

  1. Inherent Data Variability: Data collected from the real world often contains inherent noise and randomness. Even with a perfect model, there will always be a level of unpredictability in the data.

  2. Measurement Error: Data may be subject to measurement errors, inaccuracies, or imprecisions, which introduce noise and contribute to the irreducible error.

  3. Unaccounted Variables: There may be unobserved or unmeasured variables that influence the outcome but are not included in the model, leading to unpredictability.

  4. Random Events: Some processes, particularly in fields like finance or complex natural systems, are influenced by random events that cannot be modelled or predicted accurately.

The presence of irreducible error is an essential concept in statistics and machine learning. It emphasises that there is a limit to how well a model can perform, as some level of error will always be present due to the intrinsic unpredictability in the data.

Modellers must focus on reducing bias and variance (the reducible components of error) while acknowledging and accepting the existence of irreducible errors in their predictions and analyses.

Let’s define bias and variance concepts.

Bias and variance in detail, the bias-variance challenge and the Python code follow below.

Bias–variance challenge

πŸ”’ Subscribe to keep reading.

Striking the Right Balance

πŸ”’ Subscribe to keep reading.

Computing Bias and Variance in Python with scikit-learn

πŸ”’ Subscribe to keep reading.

Conclusion: Finding the Bias-Variance Sweet Spot

πŸ”’ Subscribe to keep reading.

References

πŸ”’ Subscribe to keep reading.

You've hit a Deep Dive tutorial.

I spend dozens of hours researching, coding, and breaking things to write these guides. This content is free, but reserved for my subscriber community. Drop your email below to unlock this guide (and all past/future deep dives):

Already a subscriber? Use the magic link from your last newsletter, or reset your password.

New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in β€” use the same email afterwards.

desktop bg dark

About Elena

Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.




Citation
Elena Daehnhardt. (2023) 'Bias-Variance Challenge', daehnhardt.com, 10 November 2023. Available at: https://daehnhardt.com/blog/2023/11/10/bias-variance-challenge/
All Posts