4.7 Bias-Variance decomposition
In this section we will see another approach for understanding how model complexity affects statistical learning. Instead of bounding the difference between \(E_{out}\) and \(E_{in}\) we will decompose \(E_{out}\) into two different error terms.
We consider the regression problem and therefore we assume a quadratic loss function, \[ E_{out}(h) = E\left[ (Y- h(X))^2 \right]. \] If \(h^{\mathcal D}\) is the final hypothesis that was learnt from the data \(\mathcal D\), we also define \[ \bar h(x) := E\left[h^{\mathcal D}(x))\right]. \] This is the average function that we would learn, averaged over all different datasets. It is just a theoretical tool and nothing that we would be able to calculate in practice.
First note that we can always write \[ Y = f(X) + \varepsilon, \] where \(E\left[ \varepsilon \right] = 0\). This is because if we take \(f(X) = E[Y\mid X]\), \[ E\left[\varepsilon\right] = E\left[ Y-f(X) \right] = E\left[ Y - E\left[ Y\mid X \right] \right] = E\left[ Y\right]- E\left[ Y\right] = 0. \] First let us see what the population minimizer of the error is. That is, assuming that we know the distribution of \(X,Y\), we would like to find the optimal choice of \(h\). We do this by conditioning on \(X\) and decomposing the error into two parts: \[\begin{align*} &E\left[ (Y-h(X))^2 \mid X \right] = E\left[ (Y - E[Y\mid X] + E[Y\mid X] -h(X))^2 \mid X \right] \\ =&E\left[ (Y- E[Y\mid X])^2 \mid X \right] + E\left[ ( E[Y\mid X] - h(X))^2 \mid X \right] \\ &+ \underbrace{2E\left[ (Y- E[Y\mid X])( E[Y\mid X] - h(X)) \mid X \right]}_{=0}\\ =&E\left[ (Y- E[Y\mid X])^2 \mid X \right] + E\left[ ( E[Y\mid X] - h(X))^2 \mid X \right] \end{align*}\] The first part does not depend on \(h\) and the second part is minimized by choosing \(h(x) = E[Y\mid X=x]\) for every \(x\), which therefore is the population minimizer of the error.
Coming back slightly to reality, we do not know the distribution of \((X,Y)\) but we have a training set \(\mathcal D\). So we now take the frequentist point of view and consider the squared difference between the function learnt from data, \(h^\mathcal D\) and the true regression function \(f(x)\), averaged with respect to \(\mathcal D\). \[\begin{align} &E\left[ (h^{\mathcal D}(x) - f(x))^2\right] = E\left[ (h^{\mathcal D}(x) - \bar h(x) + \bar h(x) - f(x) )^2\right] \\ =& E\left[ (h^{\mathcal D}(x) - \bar h(x) )^2\right] + E\left[ (\bar h(x) - f(x) )^2\right] +2(\bar h(x) - f(x)) E\left[ (h^{\mathcal D}(x) - \bar h(x) )\right]\\ =& E\left[ (h^{\mathcal D}(x) - \bar h(x) )^2\right] + (\bar h(x) - f(x) )^2 \end{align}\] The first term is the variance of \(h^\mathcal D\) thinking of the data set \(\mathcal D\) as random. The second term is the difference between the average function \(\bar h\) and the true regression function \(f(x)\) and is called the bias. This is the Bias-variance decomposition.
If we choose a large class of functions \(\mathcal H\) from which we choose \(h^\mathcal D\), it will be possible to closely approximate \(f\), on average. In this case the bias will be small. However, many times if \(\mathcal H\) is large, \(h^\mathcal D\) will be sensitive to data, that is we will overfit, and then the variance term is large. This is known as the trade-off between bias and variance. However it is important to understand that this trade-off is an empirical observation and not an theoretical fact. We can illustrate this with a picture similar to what we saw in the discussion of generalization error.
Figure 4.16: Sketch of the bias-variance decomposition