Bias–variance tradeoff explained

In statistics and machine learning, the bias–variance tradeoff describes the relationship between a model's complexity, the accuracy of its predictions, and how well it can make predictions on previously unseen data that were not used to train the model. In general, as we increase the number of tunable parameters in a model, it becomes more flexible, and can better fit a training data set. It is said to have lower error, or bias. However, for more flexible models, there will tend to be greater variance to the model fit each time we take a set of samples to create a new training data set. It is said that there is greater variance in the model's estimated parameters.

The bias–variance dilemma or bias–variance problem is the conflict in trying to simultaneously minimize these two sources of error that prevent supervised learning algorithms from generalizing beyond their training set:[1] [2]

The bias–variance decomposition is a way of analyzing a learning algorithm's expected generalization error with respect to a particular problem as a sum of three terms, the bias, variance, and a quantity called the irreducible error, resulting from noise in the problem itself.

Motivation

See also: Accuracy and precision. The bias–variance tradeoff is a central problem in supervised learning. Ideally, one wants to choose a model that both accurately captures the regularities in its training data, but also generalizes well to unseen data. Unfortunately, it is typically impossible to do both simultaneously. High-variance learning methods may be able to represent their training set well but are at risk of overfitting to noisy or unrepresentative training data. In contrast, algorithms with high bias typically produce simpler models that may fail to capture important regularities (i.e. underfit) in the data.

It is an often made fallacy[3] [4] to assume that complex models must have high variance. High variance models are "complex" in some sense, but the reverse needs not be true.[5] In addition, one has to be careful how to define complexity. In particular, the number of parameters used to describe the model is a poor measure of complexity. This is illustrated by an example adapted from:[6] The model

fa,b(x)=a\sin(bx)

has only two parameters (

a,b

) but it can interpolate any number of points by oscillating with a high enough frequency, resulting in both a high bias and high variance.

An analogy can be made to the relationship between accuracy and precision. Accuracy is a description of bias and can intuitively be improved by selecting from only local information. Consequently, a sample will appear accurate (i.e. have low bias) under the aforementioned selection conditions, but may result in underfitting. In other words, test data may not agree as closely with training data, which would indicate imprecision and therefore inflated variance. A graphical example would be a straight line fit to data exhibiting quadratic behavior overall. Precision is a description of variance and generally can only be improved by selecting information from a comparatively larger space. The option to select many data points over a broad sample space is the ideal condition for any analysis. However, intrinsic constraints (whether physical, theoretical, computational, etc.) will always play a limiting role. The limiting case where only a finite number of data points are selected over a broad sample space may result in improved precision and lower variance overall, but may also result in an overreliance on the training data (overfitting). This means that test data would also not agree as closely with the training data, but in this case the reason is inaccuracy or high bias. To borrow from the previous example, the graphical representation would appear as a high-order polynomial fit to the same data exhibiting quadratic behavior. Note that error in each case is measured the same way, but the reason ascribed to the error is different depending on the balance between bias and variance. To mitigate how much information is used from neighboring observations, a model can be smoothed via explicit regularization, such as shrinkage.

Bias–variance decomposition of mean squared error

See main article: Mean squared error. Suppose that we have a training set consisting of a set of points

x1,...,xn

and real values

yi

associated with each point

xi

. We assume that the data is generated by a function

f(x)

such as

y=f(x)+\varepsilon

, where the noise,

\varepsilon

, has zero mean and variance

\sigma2

.

We want to find a function

\hat{f}(x;D)

, that approximates the true function

f(x)

as well as possible, by means of some learning algorithm based on a training dataset (sample)

D=\{(x1,y1)...,(xn,yn)\}

. We make "as well as possible" precise by measuring the mean squared error between

y

and

\hat{f}(x;D)

: we want

(y-\hat{f}(x;D))2

to be minimal, both for

x1,...,xn

and for points outside of our sample. Of course, we cannot hope to do so perfectly, since the

yi

contain noise

\varepsilon

; this means we must be prepared to accept an irreducible error in any function we come up with.

Finding an

\hat{f}

that generalizes to points outside of the training set can be done with any of the countless algorithms used for supervised learning. It turns out that whichever function

\hat{f}

we select, we can decompose its expected error on an unseen sample

x

(i.e. conditional to x) as follows:[7] [8]

\operatorname{E}D,[(y-\hat{f}(x;D))2] =(\operatorname{Bias}D[\hat{f}(x;D)])2+\operatorname{Var}D[\hat{f}(x;D)]+\sigma2

where

\operatorname{Bias}D[\hat{f}(x;D)]=\operatorname{E}D[\hat{f}(x;D)-f(x)]=\operatorname{E}D[\hat{f}(x;D)]-\operatorname{E}y|x[y(x)],

\operatorname{Var}D[\hat{f}(x;D)]=\operatorname{E}D[(\operatorname{E}D[\hat{f}(x;D)]-\hat{f}(x;D))2].

and

2=\operatorname{E}
\sigma
y[(y-\underbrace{f(x)}
Ey|x[y]

)2]

The expectation ranges over different choices of the training set

D=\{(x1,y1)...,(xn,yn)\}

, all sampled from the same joint distribution

P(x,y)

which can for example be done via bootstrapping.The three terms represent:

f(x)

using a learning method for linear models, there will be error in the estimates

\hat{f}(x)

due to this assumption;

\hat{f}(x)

will move around its mean;

\sigma2

.

Since all three terms are non-negative, the irreducible error forms a lower bound on the expected error on unseen samples.

The more complex the model

\hat{f}(x)

is, the more data points it will capture, and the lower the bias will be. However, complexity will make the model "move" more to capture the data points, and hence its variance will be larger.

Derivation

The derivation of the bias–variance decomposition for squared error proceeds as follows.[9] [10] For notational convenience, we abbreviate

f=f(x)

,

\hat{f}=\hat{f}(x;D)

and we drop the

D

subscript on our expectation operators.

Let us write the mean-squared error of our model:

MSE\triangleq \operatorname{E}[(y-\hat{f})2]=\operatorname{E}[y2-2y\hat{f}+\hat{f}2]=\operatorname{E}[y2]-2\operatorname{E}[y\hat{f}]+\operatorname{E}[\hat{f}2]

Firstly, since we model

y=f+\varepsilon

, we show that

\begin{align} \operatorname{E}[y2]&=\operatorname{E}[(f+\varepsilon)2]\\ &=\operatorname{E}[f2]+2\operatorname{E}[f\varepsilon]+\operatorname{E}[\varepsilon2]&&bylinearityof\operatorname{E}\\ &=f2+2f\operatorname{E}[\varepsilon]+\operatorname{E}[\varepsilon2]&&sincefdoesnotdependonthedata\\ &=f2+2f0+\sigma2&&since\varepsilonhaszeromeanandvariance\sigma2 \end{align}

Secondly,

\begin{align} \operatorname{E}[y\hat{f}]&=\operatorname{E}[(f+\varepsilon)\hat{f}]\\ &=\operatorname{E}[f\hat{f}]+\operatorname{E}[\varepsilon\hat{f}]&&bylinearityof\operatorname{E}\\ &=\operatorname{E}[f\hat{f}]+\operatorname{E}[\varepsilon]\operatorname{E}[\hat{f}]&&since\hat{f}and\varepsilonareindependent\\ &=f\operatorname{E}[\hat{f}]&&since\operatorname{E}[\varepsilon]=0 \end{align}

Lastly,

\begin{align} \operatorname{E}[\hat{f}2]&=\operatorname{Var}(\hat{f})+\operatorname{E}[\hat{f}]2&&since\operatorname{Var}[X]\triangleq\operatorname{E}[(X-\operatorname{E}[X])2]=\operatorname{E}[X2]-\operatorname{E}[X]2foranyrandomvariableX \end{align}

Eventually, we plug these 3 formulas in our previous derivation of

MSE

and thus show that:

\begin{align} MSE &=f2+\sigma2-2f\operatorname{E}[\hat{f}]+\operatorname{Var}[\hat{f}]+\operatorname{E}[\hat{f}]2\\ &=(f-\operatorname{E}[\hat{f}])2+\sigma2+\operatorname{Var}[\hat{f}]\\[5pt] &=\operatorname{Bias}[\hat{f}]2+\sigma2+\operatorname{Var}[\hat{f}] \end{align}

Finally, MSE loss function (or negative log-likelihood) is obtained by taking the expectation value over

x\simP

:

MSE=\operatorname{E}x\{\operatorname{Bias}

2+\operatorname{Var}
D[\hat{f}(x;D)]\}

+\sigma2.

Approaches

Dimensionality reduction and feature selection can decrease variance by simplifying models. Similarly, a larger training set tends to decrease variance. Adding features (predictors) tends to decrease bias, at the expense of introducing additional variance. Learning algorithms typically have some tunable parameters that control bias and variance; for example,

One way of resolving the trade-off is to use mixture models and ensemble learning.[14] [15] For example, boosting combines many "weak" (high bias) models in an ensemble that has lower bias than the individual models, while bagging combines "strong" learners in a way that reduces their variance.

Model validation methods such as cross-validation (statistics) can be used to tune models so as to optimize the trade-off.

k-nearest neighbors

In the case of -nearest neighbors regression, when the expectation is taken over the possible labeling of a fixed training set, a closed-form expression exists that relates the bias–variance decomposition to the parameter :

\operatorname{E}\left[(y-\hat{f}(x))2\midX=x\right]=\left(f(x)-

1
k
k
\sum
i=1

f(Ni(x))\right)2+

\sigma2
k

+\sigma2

where

N1(x),...,Nk(x)

are the nearest neighbors of in the training set. The bias (first term) is a monotone rising function of, while the variance (second term) drops off as is increased. In fact, under "reasonable assumptions" the bias of the first-nearest neighbor (1-NN) estimator vanishes entirely as the size of the training set approaches infinity.

Applications

In regression

The bias–variance decomposition forms the conceptual basis for regression regularization methods such as LASSO and ridge regression. Regularization methods introduce bias into the regression solution that can reduce variance considerably relative to the ordinary least squares (OLS) solution. Although the OLS solution provides non-biased regression estimates, the lower variance solutions produced by regularization techniques provide superior MSE performance.

In classification

The bias–variance decomposition was originally formulated for least-squares regression. For the case of classification under the 0-1 loss (misclassification rate), it is possible to find a similar decomposition, with the caveat that the variance term becomes dependent on the target label.[16] [17] Alternatively, if the classification problem can be phrased as probabilistic classification, then the expected cross-entropy can instead be decomposed to give bias and variance terms with the same semantics but taking a different form.

It has been argued that as training data increases, the variance of learned models will tend to decrease, and hence that as training data quantity increases, error is minimised by methods that learn models with lesser bias, and that conversely, for smaller training data quantities it is ever more important to minimise variance.[18]

In reinforcement learning

Even though the bias–variance decomposition does not directly apply in reinforcement learning, a similar tradeoff can also characterize generalization. When an agent has limited information on its environment, the suboptimality of an RL algorithm can be decomposed into the sum of two terms: a term related to an asymptotic bias and a term due to overfitting. The asymptotic bias is directly related to the learning algorithm (independently of the quantity of data) while the overfitting term comes from the fact that the amount of data is limited.[19]

In human learning

While widely discussed in the context of machine learning, the bias–variance dilemma has been examined in the context of human cognition, most notably by Gerd Gigerenzer and co-workers in the context of learned heuristics. They have argued (see references below) that the human brain resolves the dilemma in the case of the typically sparse, poorly-characterized training-sets provided by experience by adopting high-bias/low variance heuristics. This reflects the fact that a zero-bias approach has poor generalizability to new situations, and also unreasonably presumes precise knowledge of the true state of the world. The resulting heuristics are relatively simple, but produce better inferences in a wider variety of situations.[20]

Geman et al. argue that the bias–variance dilemma implies that abilities such as generic object recognition cannot be learned from scratch, but require a certain degree of "hard wiring" that is later tuned by experience. This is because model-free approaches to inference require impractically large training sets if they are to avoid high variance.

See also

External links

Notes and References

  1. Kohavi . Ron . Wolpert . David H. . Bias Plus Variance Decomposition for Zero-One Loss Functions . ICML . 1996 . 96.
  2. Luxburg . Ulrike V. . Schölkopf . B. . Statistical learning theory: Models, concepts, and results . Handbook of the History of Logic . 2011 . 10. Section 2.4.
  3. Neal . Brady . 1912.08286 . On the Bias-Variance Tradeoff: Textbooks Need an Update . cs.LG . 2019.
  4. Brady . Neal . Sarthak . Mittal . Aristide . Baratin . Vinayak . Tantia . Matthew . Scicluna . Simon . Lacoste-Julien . Ioannis . Mitliagkas . 1810.08591 . A Modern Take on the Bias-Variance Tradeoff in Neural Networks . cs.LG . 2018.
  5. Neal . Brady . Mittal . Sarthak . Baratin . Aristide . Tantia . Vinayak . Scicluna . Matthew . Lacoste-Julien . Simon . Mitliagkas . Ioannis . 2019 . A Modern Take on the Bias-Variance Tradeoff in Neural Networks . International Conference on Learning Representations (ICLR) 2019.
  6. Book: Vapnik . Vladimir . The nature of statistical learning theory . 2000 . Springer-Verlag . New York . 10.1007/978-1-4757-3264-1 . 978-1-4757-3264-1 . 7138354 .
  7. Book: Gareth . James . Daniela . Witten . Daniela Witten . Trevor . Hastie . Trevor Hastie . Robert . Tibshirani . Robert Tibshirani . An Introduction to Statistical Learning . Springer . 2013 .
  8. Book: Trevor . Hastie . Robert . Tibshirani . Jerome H. . Friedman . Jerome H. Friedman . 2009 . The Elements of Statistical Learning . 2014-08-20 . https://web.archive.org/web/20150126123924/http://statweb.stanford.edu/~tibs/ElemStatLearn/ . 2015-01-26 . dead .
  9. Web site: Sethu . Vijayakumar . Sethu Vijayakumar . The Bias–Variance Tradeoff . . 2007 . 19 August 2014 .
  10. Web site: Notes on derivation of bias-variance decomposition in linear regression . Greg . Shakhnarovich . 2011 . 20 August 2014 . https://web.archive.org/web/20140821063842/http://ttic.uchicago.edu/~gregory/courses/wis-ml2012/lectures/biasVarDecom.pdf . 21 August 2014 .
  11. Book: Belsley, David . Conditioning diagnostics : collinearity and weak data in regression . Wiley . New York (NY) . 1991 . 978-0471528890 .
  12. Geman . Stuart . Stuart Geman . Élie . Bienenstock . René . Doursat . 1992 . Neural networks and the bias/variance dilemma . Neural Computation . 4 . 1–58 . 10.1162/neco.1992.4.1.1 . 14215320 .
  13. Gagliardi . Francesco . May 2011 . Instance-based classifiers applied to medical databases: diagnosis and knowledge extraction . Artificial Intelligence in Medicine . 52 . 3 . 123–139 . 10.1016/j.artmed.2011.04.002 . 21621400 .
  14. Book: Jo-Anne . Ting . Sethu . Vijaykumar . Stefan . Schaal . Encyclopedia of Machine Learning . Locally Weighted Regression for Control . Claude . Sammut . Geoffrey I. . Webb . Springer . 2011 . 615 . 2010eoml.book.....S .
  15. Web site: Scott . Fortmann-Roe . Understanding the Bias–Variance Tradeoff . 2012 .
  16. Domingos . Pedro . Pedro Domingos . A unified bias-variance decomposition . ICML . 2000 .
  17. Giorgio . Valentini . Thomas G. . Dietterich . Thomas G. Dietterich . Bias–variance analysis of support vector machines for the development of SVM-based ensemble methods . . 5 . 2004 . 725–775 .
  18. Brain. Damian. Webb. Geoffrey. Geoff Webb. The Need for Low Bias Algorithms in Classification Learning From Large Data Sets. Proceedings of the Sixth European Conference on Principles of Data Mining and Knowledge Discovery (PKDD 2002). 2002 .
  19. Vincent . Francois-Lavet . Guillaume . Rabusseau . Joelle . Pineau . Damien . Ernst . Raphael . Fonteneau . On Overfitting and Asymptotic Bias in Batch Reinforcement Learning with Partial Observability . Journal of Artificial Intelligence Research. 65 . 2019 . 1–30 . 10.1613/jair.1.11478 . free . 1709.07796 .
  20. Gigerenzer . Gerd . Gerd Gigerenzer . Brighton . Henry . 10.1111/j.1756-8765.2008.01006.x . Homo Heuristicus: Why Biased Minds Make Better Inferences . Topics in Cognitive Science . 1 . 1 . 107–143 . 2009 . 25164802 . 11858/00-001M-0000-0024-F678-0 . free .