Bias and Variance

Machine Learning
Author

Shane Oh

Published

September 7, 2023

Refer to the lecture note by Kilian Weinberger.

Let \(f(x)\) be the unknown function and \(\epsilon \sim \mathcal{N}(0, \sigma_\epsilon^2)\) be the noise when observing the reality. Then, we can set \(y = f(x) + \epsilon\).

\[ \begin{align*} \mathbb{E}[((y - \hat{f}_D(x)))^2] &= \mathbb{E}[(f(x) + \epsilon - \hat{f}_D(x))^2] \\ &= \mathbb{E}[(f(x) - \hat{f}_D(x))^2 + 2\epsilon(f(x) - \hat{f}_D(x)) + \epsilon^2] \\ &= \mathbb{E}[(f(x) - \hat{f}_D(x))^2] + 2\mathbb{E}[\epsilon(f(x) - \hat{f}_D(x))] + \mathbb{E}[\epsilon^2] \\ &= \mathbb{E}[(f(x) - \hat{f}_D(x))^2] + 2\mathbb{E}[\epsilon(f(x) - \hat{f}_D(x))] + \mathbb{E}[\epsilon^2] \\ &= \mathbb{E}[(f(x) - \hat{f}_D(x))^2] + \sigma_\epsilon^2 \\ &= \mathbb{E}[(f(x) - \bar{f}(x) + \bar{f}(x) - \hat{f}_D(x))^2] + \sigma_\epsilon^2 \\ &= \mathbb{E}[(f(x) - \bar{f}(x))^2 + 2(f(x) - \bar{f}(x))(\bar{f}(x) - \hat{f}_D(x)) + (\bar{f}(x) - \hat{f}_D(x))^2] + \sigma_\epsilon^2 \\ &= \underbrace{\mathbb{E}[(f(x) - \bar{f}(x))^2]}_{\text{bias}^2} + \underbrace{\mathbb{E}[(\bar{f}(x) - \hat{f}_D(x))^2]}_\text{variance} + \underbrace{\sigma_\epsilon^2}_{\text{noise}} \\ \end{align*} \]