Mean Squared Error

The mean squared error (MSE) averages the squared residuals of predictions:

Here is the true value, is the prediction and is the residual. The pointwise loss is the squared error , also called the L2 loss, and MSE is its empirical risk. Least squares minimizes the sum , which has the same minimizer. The root mean squared error returns to the units of :

MSE has five headline facts:

  • Minimizer: the best constant prediction is the sample mean . Over all functions of , the population risk is minimized by the conditional mean .
  • Gaussian likelihood: if independently, the negative log-likelihood is . Minimizing MSE is then maximum likelihood, and the MLE of is the training MSE.
  • Gradient: , so each point pulls on the fit in proportion to its residual.
  • Outliers: a residual times larger contributes times more, so a few large errors can dominate MSE.
  • Bias and variance: the expected test MSE of a learned model splits into noise, squared bias and variance (2.3.1. Bias-Variance Decomposition).

MSE is the default loss and metric for regression. MAE replaces it when outliers dominate, and Huber loss combines the two.

Intuition

The name lists the steps. Take each error, square it, and average the squares. The square of any error is nonnegative, so errors in opposite directions cannot cancel. The square also weighs each error by its own size. One error of contributes , while ten errors of contribute in total. A model trained on MSE therefore works hardest on its worst predictions. MSE is in squared units of , such as squared dollars, which are hard to read. RMSE takes the square root and returns to dollars.

Squared error has two further justifications. The best constant guess under squared error is the mean, and the best guess given is the conditional mean. A model trained on MSE therefore estimates the average outcome for each input. MSE also follows from a noise model. If the noise is Gaussian with constant variance, the most likely parameters are the least squares parameters. Least squares therefore works well when the noise is close to Gaussian and poorly when the noise has heavy tails.

The animation runs gradient descent on the MSE of a line fit to eight points. The right panel draws the MSE as a bowl over . The line on the left improves at each step.

\usepackage{tikz}
\usetikzlibrary{animations, arrows.meta}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\definecolor{mid}{HTML}{8A8A8A}
\newcommand{\q}[4]{\filldraw[draw=mid, fill=white] (#1) -- (#2) -- (#3) -- (#4) -- cycle;}
\newcommand{\pt}[1]{\filldraw[draw=black, fill=mid] (#1) circle (2.6pt);}
\begin{tikzpicture}[font=\small, >={Stealth[length=2.2mm]}]
\draw[mid] (7.00,2.99) -- (9.74,-0.18) -- (15.20,1.61) -- (12.46,4.78) -- cycle;
\draw[->] (7.00,2.99) -- (7.00,4.71);
\node[anchor=south] at (7.00,4.71) {$\mathrm{MSE}$};
\draw (6.93,3.45) -- (7.07,3.45) node[pos=0, left] {\footnotesize $2$};
\draw (6.93,3.90) -- (7.07,3.90) node[pos=0, left] {\footnotesize $4$};
\draw (6.93,4.36) -- (7.07,4.36) node[pos=0, left] {\footnotesize $6$};
\draw[->] (7.00,2.99) -- (10.04,-0.52);
\node[anchor=north west, inner sep=1pt] at (10.04,-0.52) {$\beta_0$};
\draw[->] (9.74,-0.18) -- (15.90,1.84);
\node[anchor=south west, inner sep=1pt] at (15.90,1.84) {$\beta_1$};
\draw (7.23,2.73) -- (7.10,2.68) node[anchor=north, inner sep=2pt] {\footnotesize $-1$};
\draw (7.77,2.10) -- (7.64,2.06) node[anchor=north, inner sep=2pt] {\footnotesize $0$};
\draw (8.31,1.48) -- (8.18,1.43) node[anchor=north, inner sep=2pt] {\footnotesize $1$};
\draw (8.85,0.85) -- (8.72,0.81) node[anchor=north, inner sep=2pt] {\footnotesize $2$};
\draw (9.39,0.23) -- (9.26,0.18) node[anchor=north, inner sep=2pt] {\footnotesize $3$};
\draw (10.81,0.17) -- (10.88,0.09) node[anchor=north west, inner sep=1pt] {\footnotesize $0$};
\draw (12.82,0.83) -- (12.89,0.74) node[anchor=north west, inner sep=1pt] {\footnotesize $1$};
\draw (14.83,1.48) -- (14.90,1.40) node[anchor=north west, inner sep=1pt] {\footnotesize $2$};
\q{11.46,5.02}{11.48,5.29}{10.91,5.30}{10.92,5.03}
\q{11.43,4.74}{11.46,5.02}{10.92,5.03}{10.93,4.75}
\q{10.92,5.03}{10.91,5.30}{10.34,5.24}{10.39,4.97}
\q{10.93,4.75}{10.92,5.03}{10.39,4.97}{10.44,4.70}
\q{11.40,4.45}{11.43,4.74}{10.93,4.75}{10.95,4.46}
\q{11.98,4.94}{12.04,5.20}{11.48,5.29}{11.46,5.02}
\q{10.95,4.46}{10.93,4.75}{10.44,4.70}{10.50,4.41}
\q{11.91,4.67}{11.98,4.94}{11.46,5.02}{11.43,4.74}
\q{11.37,4.15}{11.40,4.45}{10.95,4.46}{10.96,4.16}
\q{11.84,4.38}{11.91,4.67}{11.43,4.74}{11.40,4.45}
\q{10.96,4.16}{10.95,4.46}{10.50,4.41}{10.56,4.11}
\q{11.76,4.09}{11.84,4.38}{11.40,4.45}{11.37,4.15}
\q{10.39,4.97}{10.34,5.24}{9.81,5.11}{9.89,4.85}
\q{11.33,3.83}{11.37,4.15}{10.96,4.16}{10.98,3.84}
\q{10.44,4.70}{10.39,4.97}{9.89,4.85}{9.98,4.58}
\q{10.50,4.41}{10.44,4.70}{9.98,4.58}{10.08,4.31}
\q{10.98,3.84}{10.96,4.16}{10.56,4.11}{10.64,3.80}
\q{11.68,3.78}{11.76,4.09}{11.37,4.15}{11.33,3.83}
\q{10.56,4.11}{10.50,4.41}{10.08,4.31}{10.19,4.02}
\q{12.46,4.79}{12.56,5.05}{12.04,5.20}{11.98,4.94}
\q{12.36,4.53}{12.46,4.79}{11.98,4.94}{11.91,4.67}
\q{12.25,4.26}{12.36,4.53}{11.91,4.67}{11.84,4.38}
\q{11.29,3.48}{11.33,3.83}{10.98,3.84}{11.00,3.48}
\q{12.13,3.98}{12.25,4.26}{11.84,4.38}{11.76,4.09}
\q{10.64,3.80}{10.56,4.11}{10.19,4.02}{10.31,3.72}
\q{11.00,3.48}{10.98,3.84}{10.64,3.80}{10.72,3.45}
\q{11.57,3.43}{11.68,3.78}{11.33,3.83}{11.29,3.48}
\q{11.99,3.68}{12.13,3.98}{11.76,4.09}{11.68,3.78}
\q{10.72,3.45}{10.64,3.80}{10.31,3.72}{10.45,3.39}
\q{9.98,4.58}{9.89,4.85}{9.45,4.66}{9.57,4.41}
\q{10.08,4.31}{9.98,4.58}{9.57,4.41}{9.70,4.15}
\q{9.89,4.85}{9.81,5.11}{9.33,4.91}{9.45,4.66}
\q{10.19,4.02}{10.08,4.31}{9.70,4.15}{9.85,3.88}
\q{11.83,3.36}{11.99,3.68}{11.68,3.78}{11.57,3.43}
\q{10.31,3.72}{10.19,4.02}{9.85,3.88}{10.02,3.60}
\q{11.24,3.07}{11.29,3.48}{11.00,3.48}{11.03,3.07}
\q{11.03,3.07}{11.00,3.48}{10.72,3.45}{10.83,3.05}
\q{12.61,4.09}{12.75,4.34}{12.36,4.53}{12.25,4.26}
\q{12.75,4.34}{12.89,4.59}{12.46,4.79}{12.36,4.53}
\q{11.43,3.04}{11.57,3.43}{11.29,3.48}{11.24,3.07}
\q{12.45,3.82}{12.61,4.09}{12.25,4.26}{12.13,3.98}
\q{12.89,4.59}{13.01,4.83}{12.56,5.05}{12.46,4.79}
\q{10.45,3.39}{10.31,3.72}{10.02,3.60}{10.22,3.29}
\q{12.27,3.55}{12.45,3.82}{12.13,3.98}{11.99,3.68}
\q{10.83,3.05}{10.72,3.45}{10.45,3.39}{10.64,3.01}
\q{11.61,2.98}{11.83,3.36}{11.57,3.43}{11.43,3.04}
\q{12.05,3.25}{12.27,3.55}{11.99,3.68}{11.83,3.36}
\q{10.64,3.01}{10.45,3.39}{10.22,3.29}{10.48,2.94}
\q{9.85,3.88}{9.70,4.15}{9.39,3.95}{9.57,3.70}
\q{10.02,3.60}{9.85,3.88}{9.57,3.70}{9.77,3.44}
\q{9.70,4.15}{9.57,4.41}{9.22,4.19}{9.39,3.95}
\q{11.78,2.91}{12.05,3.25}{11.83,3.36}{11.61,2.98}
\q{9.57,4.41}{9.45,4.66}{9.07,4.43}{9.22,4.19}
\q{10.22,3.29}{10.02,3.60}{9.77,3.44}{10.02,3.16}
\q{9.45,4.66}{9.33,4.91}{8.93,4.66}{9.07,4.43}
\q{12.50,3.38}{12.71,3.63}{12.45,3.82}{12.27,3.55}
\q{12.71,3.63}{12.90,3.87}{12.61,4.09}{12.45,3.82}
\q{12.24,3.11}{12.50,3.38}{12.27,3.55}{12.05,3.25}
\q{12.90,3.87}{13.07,4.11}{12.75,4.34}{12.61,4.09}
\q{10.48,2.94}{10.22,3.29}{10.02,3.16}{10.33,2.85}
\q{13.07,4.11}{13.23,4.34}{12.89,4.59}{12.75,4.34}
\q{11.91,2.81}{12.24,3.11}{12.05,3.25}{11.78,2.91}
\q{13.23,4.34}{13.38,4.56}{13.01,4.83}{12.89,4.59}
\q{10.02,3.16}{9.77,3.44}{9.59,3.26}{9.86,3.01}
\q{11.10,2.31}{11.24,3.07}{11.03,3.07}{11.10,2.31}
\q{11.10,2.31}{11.03,3.07}{10.83,3.05}{11.10,2.31}
\q{9.77,3.44}{9.57,3.70}{9.35,3.49}{9.59,3.26}
\q{11.10,2.31}{11.43,3.04}{11.24,3.07}{11.10,2.31}
\q{10.33,2.85}{10.02,3.16}{9.86,3.01}{10.23,2.74}
\q{11.10,2.31}{10.83,3.05}{10.64,3.01}{11.10,2.31}
\q{9.57,3.70}{9.39,3.95}{9.15,3.71}{9.35,3.49}
\q{11.10,2.31}{11.61,2.98}{11.43,3.04}{11.10,2.31}
\q{11.10,2.31}{10.64,3.01}{10.48,2.94}{11.10,2.31}
\q{9.39,3.95}{9.22,4.19}{8.96,3.93}{9.15,3.71}
\q{12.37,2.96}{12.66,3.19}{12.50,3.38}{12.24,3.11}
\q{12.00,2.70}{12.37,2.96}{12.24,3.11}{11.91,2.81}
\q{11.10,2.31}{11.78,2.91}{11.61,2.98}{11.10,2.31}
\q{12.66,3.19}{12.90,3.41}{12.71,3.63}{12.50,3.38}
\q{9.22,4.19}{9.07,4.43}{8.79,4.15}{8.96,3.93}
\q{11.10,2.31}{10.48,2.94}{10.33,2.85}{11.10,2.31}
\q{12.90,3.41}{13.11,3.63}{12.90,3.87}{12.71,3.63}
\q{11.10,2.31}{11.91,2.81}{11.78,2.91}{11.10,2.31}
\q{9.07,4.43}{8.93,4.66}{8.63,4.36}{8.79,4.15}
\q{13.11,3.63}{13.31,3.84}{13.07,4.11}{12.90,3.87}
\q{11.10,2.31}{10.33,2.85}{10.23,2.74}{11.10,2.31}
\q{10.23,2.74}{9.86,3.01}{9.77,2.84}{10.16,2.62}
\q{11.10,2.31}{12.00,2.70}{11.91,2.81}{11.10,2.31}
\q{9.86,3.01}{9.59,3.26}{9.47,3.05}{9.77,2.84}
\q{13.31,3.84}{13.48,4.04}{13.23,4.34}{13.07,4.11}
\q{11.10,2.31}{10.23,2.74}{10.16,2.62}{11.10,2.31}
\q{12.06,2.58}{12.45,2.79}{12.37,2.96}{12.00,2.70}
\q{9.59,3.26}{9.35,3.49}{9.21,3.25}{9.47,3.05}
\q{11.10,2.31}{12.06,2.58}{12.00,2.70}{11.10,2.31}
\q{13.48,4.04}{13.65,4.25}{13.38,4.56}{13.23,4.34}
\q{12.45,2.79}{12.76,2.98}{12.66,3.19}{12.37,2.96}
\q{11.10,2.31}{10.16,2.62}{10.13,2.50}{11.10,2.31}
\q{9.35,3.49}{9.15,3.71}{8.99,3.45}{9.21,3.25}
\q{11.10,2.31}{12.07,2.46}{12.06,2.58}{11.10,2.31}
\q{12.76,2.98}{13.01,3.17}{12.90,3.41}{12.66,3.19}
\q{10.16,2.62}{9.77,2.84}{9.73,2.67}{10.13,2.50}
\q{9.15,3.71}{8.96,3.93}{8.79,3.64}{8.99,3.45}
\q{11.10,2.31}{10.13,2.50}{10.14,2.37}{11.10,2.31}
\q{11.10,2.31}{12.04,2.33}{12.07,2.46}{11.10,2.31}
\q{12.07,2.46}{12.47,2.61}{12.45,2.79}{12.06,2.58}
\q{13.01,3.17}{13.24,3.36}{13.11,3.63}{12.90,3.41}
\q{9.77,2.84}{9.47,3.05}{9.42,2.84}{9.73,2.67}
\q{8.96,3.93}{8.79,4.15}{8.61,3.83}{8.79,3.64}
\q{11.10,2.31}{10.14,2.37}{10.20,2.25}{11.10,2.31}
\q{11.10,2.31}{11.97,2.21}{12.04,2.33}{11.10,2.31}
\q{13.24,3.36}{13.44,3.54}{13.31,3.84}{13.11,3.63}
\q{12.47,2.61}{12.78,2.77}{12.76,2.98}{12.45,2.79}
\q{8.79,4.15}{8.63,4.36}{8.43,4.02}{8.61,3.83}
\q{11.10,2.31}{10.20,2.25}{10.29,2.14}{11.10,2.31}
\q{9.47,3.05}{9.21,3.25}{9.16,3.01}{9.42,2.84}
\q{10.13,2.50}{9.73,2.67}{9.75,2.49}{10.14,2.37}
\q{11.10,2.31}{11.87,2.11}{11.97,2.21}{11.10,2.31}
\q{13.44,3.54}{13.63,3.73}{13.48,4.04}{13.31,3.84}
\q{11.10,2.31}{10.29,2.14}{10.42,2.05}{11.10,2.31}
\q{12.04,2.33}{12.43,2.43}{12.47,2.61}{12.07,2.46}
\q{11.10,2.31}{11.72,2.02}{11.87,2.11}{11.10,2.31}
\q{12.78,2.77}{13.04,2.92}{13.01,3.17}{12.76,2.98}
\q{9.21,3.25}{8.99,3.45}{8.93,3.17}{9.16,3.01}
\q{11.10,2.31}{10.42,2.05}{10.59,1.97}{11.10,2.31}
\q{13.63,3.73}{13.81,3.91}{13.65,4.25}{13.48,4.04}
\q{11.10,2.31}{11.56,1.95}{11.72,2.02}{11.10,2.31}
\q{9.73,2.67}{9.42,2.84}{9.44,2.62}{9.75,2.49}
\q{11.10,2.31}{10.59,1.97}{10.77,1.91}{11.10,2.31}
\q{11.10,2.31}{11.37,1.90}{11.56,1.95}{11.10,2.31}
\q{11.10,2.31}{10.77,1.91}{10.96,1.88}{11.10,2.31}
\q{11.10,2.31}{11.17,1.88}{11.37,1.90}{11.10,2.31}
\q{10.14,2.37}{9.75,2.49}{9.83,2.32}{10.20,2.25}
\q{11.10,2.31}{10.96,1.88}{11.17,1.88}{11.10,2.31}
\q{8.99,3.45}{8.79,3.64}{8.72,3.34}{8.93,3.17}
\q{13.04,2.92}{13.27,3.08}{13.24,3.36}{13.01,3.17}
\q{12.43,2.43}{12.73,2.55}{12.78,2.77}{12.47,2.61}
\q{11.97,2.21}{12.34,2.27}{12.43,2.43}{12.04,2.33}
\q{9.42,2.84}{9.16,3.01}{9.19,2.76}{9.44,2.62}
\q{8.79,3.64}{8.61,3.83}{8.53,3.51}{8.72,3.34}
\q{13.27,3.08}{13.48,3.24}{13.44,3.54}{13.24,3.36}
\q{10.20,2.25}{9.83,2.32}{9.96,2.17}{10.29,2.14}
\q{12.73,2.55}{12.99,2.67}{13.04,2.92}{12.78,2.77}
\q{9.75,2.49}{9.44,2.62}{9.54,2.41}{9.83,2.32}
\q{8.61,3.83}{8.43,4.02}{8.35,3.67}{8.53,3.51}
\q{11.87,2.11}{12.18,2.12}{12.34,2.27}{11.97,2.21}
\q{9.16,3.01}{8.93,3.17}{8.96,2.89}{9.19,2.76}
\q{13.48,3.24}{13.67,3.40}{13.63,3.73}{13.44,3.54}
\q{12.34,2.27}{12.61,2.35}{12.73,2.55}{12.43,2.43}
\q{10.29,2.14}{9.96,2.17}{10.15,2.03}{10.42,2.05}
\q{12.99,2.67}{13.21,2.80}{13.27,3.08}{13.04,2.92}
\q{13.67,3.40}{13.85,3.55}{13.81,3.91}{13.63,3.73}
\q{8.93,3.17}{8.72,3.34}{8.76,3.03}{8.96,2.89}
\q{11.72,2.02}{11.98,1.99}{12.18,2.12}{11.87,2.11}
\q{9.44,2.62}{9.19,2.76}{9.30,2.52}{9.54,2.41}
\q{9.83,2.32}{9.54,2.41}{9.70,2.22}{9.96,2.17}
\q{10.42,2.05}{10.15,2.03}{10.37,1.92}{10.59,1.97}
\q{12.61,2.35}{12.85,2.44}{12.99,2.67}{12.73,2.55}
\q{13.21,2.80}{13.41,2.93}{13.48,3.24}{13.27,3.08}
\q{12.18,2.12}{12.43,2.16}{12.61,2.35}{12.34,2.27}
\q{11.56,1.95}{11.75,1.89}{11.98,1.99}{11.72,2.02}
\q{8.72,3.34}{8.53,3.51}{8.57,3.18}{8.76,3.03}
\q{9.19,2.76}{8.96,2.89}{9.09,2.63}{9.30,2.52}
\q{10.59,1.97}{10.37,1.92}{10.63,1.84}{10.77,1.91}
\q{11.37,1.90}{11.48,1.83}{11.75,1.89}{11.56,1.95}
\q{10.77,1.91}{10.63,1.84}{10.91,1.80}{10.96,1.88}
\q{9.96,2.17}{9.70,2.22}{9.93,2.06}{10.15,2.03}
\q{13.41,2.93}{13.59,3.07}{13.67,3.40}{13.48,3.24}
\q{11.17,1.88}{11.20,1.80}{11.48,1.83}{11.37,1.90}
\q{8.53,3.51}{8.35,3.67}{8.39,3.32}{8.57,3.18}
\q{10.96,1.88}{10.91,1.80}{11.20,1.80}{11.17,1.88}
\q{9.54,2.41}{9.30,2.52}{9.49,2.30}{9.70,2.22}
\q{12.85,2.44}{13.05,2.54}{13.21,2.80}{12.99,2.67}
\q{11.98,1.99}{12.18,2.01}{12.43,2.16}{12.18,2.12}
\q{8.96,2.89}{8.76,3.03}{8.89,2.74}{9.09,2.63}
\q{12.43,2.16}{12.63,2.23}{12.85,2.44}{12.61,2.35}
\q{13.59,3.07}{13.77,3.20}{13.85,3.55}{13.67,3.40}
\q{10.15,2.03}{9.93,2.06}{10.21,1.92}{10.37,1.92}
\q{13.05,2.54}{13.24,2.65}{13.41,2.93}{13.21,2.80}
\q{11.75,1.89}{11.89,1.89}{12.18,2.01}{11.98,1.99}
\q{9.30,2.52}{9.09,2.63}{9.30,2.38}{9.49,2.30}
\q{9.70,2.22}{9.49,2.30}{9.75,2.10}{9.93,2.06}
\q{8.76,3.03}{8.57,3.18}{8.72,2.86}{8.89,2.74}
\q{10.37,1.92}{10.21,1.92}{10.52,1.83}{10.63,1.84}
\q{12.63,2.23}{12.81,2.30}{13.05,2.54}{12.85,2.44}
\q{11.48,1.83}{11.56,1.81}{11.89,1.89}{11.75,1.89}
\q{12.18,2.01}{12.35,2.05}{12.63,2.23}{12.43,2.16}
\q{10.63,1.84}{10.52,1.83}{10.87,1.78}{10.91,1.80}
\q{13.24,2.65}{13.41,2.76}{13.59,3.07}{13.41,2.93}
\q{11.20,1.80}{11.22,1.77}{11.56,1.81}{11.48,1.83}
\q{10.91,1.80}{10.87,1.78}{11.22,1.77}{11.20,1.80}
\q{8.57,3.18}{8.39,3.32}{8.55,2.98}{8.72,2.86}
\q{9.09,2.63}{8.89,2.74}{9.13,2.47}{9.30,2.38}
\q{9.93,2.06}{9.75,2.10}{10.07,1.95}{10.21,1.92}
\q{9.49,2.30}{9.30,2.38}{9.59,2.16}{9.75,2.10}
\q{11.89,1.89}{12.01,1.91}{12.35,2.05}{12.18,2.01}
\q{12.81,2.30}{12.98,2.39}{13.24,2.65}{13.05,2.54}
\q{13.41,2.76}{13.57,2.87}{13.77,3.20}{13.59,3.07}
\q{12.35,2.05}{12.50,2.10}{12.81,2.30}{12.63,2.23}
\q{10.21,1.92}{10.07,1.95}{10.44,1.84}{10.52,1.83}
\q{8.89,2.74}{8.72,2.86}{8.97,2.57}{9.13,2.47}
\q{11.56,1.81}{11.64,1.81}{12.01,1.91}{11.89,1.89}
\q{10.52,1.83}{10.44,1.84}{10.83,1.78}{10.87,1.78}
\q{9.75,2.10}{9.59,2.16}{9.95,1.99}{10.07,1.95}
\q{11.22,1.77}{11.24,1.77}{11.64,1.81}{11.56,1.81}
\q{9.30,2.38}{9.13,2.47}{9.45,2.23}{9.59,2.16}
\q{12.98,2.39}{13.13,2.48}{13.41,2.76}{13.24,2.65}
\q{10.87,1.78}{10.83,1.78}{11.24,1.77}{11.22,1.77}
\q{12.01,1.91}{12.12,1.95}{12.50,2.10}{12.35,2.05}
\q{8.72,2.86}{8.55,2.98}{8.82,2.67}{8.97,2.57}
\q{12.50,2.10}{12.63,2.17}{12.98,2.39}{12.81,2.30}
\q{10.07,1.95}{9.95,1.99}{10.36,1.87}{10.44,1.84}
\q{13.13,2.48}{13.27,2.57}{13.57,2.87}{13.41,2.76}
\q{11.64,1.81}{11.70,1.84}{12.12,1.95}{12.01,1.91}
\q{9.13,2.47}{8.97,2.57}{9.31,2.31}{9.45,2.23}
\q{9.59,2.16}{9.45,2.23}{9.84,2.05}{9.95,1.99}
\q{10.44,1.84}{10.36,1.87}{10.80,1.80}{10.83,1.78}
\q{11.24,1.77}{11.25,1.79}{11.70,1.84}{11.64,1.81}
\q{12.63,2.17}{12.75,2.24}{13.13,2.48}{12.98,2.39}
\q{12.12,1.95}{12.22,2.00}{12.63,2.17}{12.50,2.10}
\q{10.83,1.78}{10.80,1.80}{11.25,1.79}{11.24,1.77}
\q{8.97,2.57}{8.82,2.67}{9.19,2.40}{9.31,2.31}
\q{9.95,1.99}{9.84,2.05}{10.29,1.91}{10.36,1.87}
\q{11.70,1.84}{11.76,1.88}{12.22,2.00}{12.12,1.95}
\q{9.45,2.23}{9.31,2.31}{9.74,2.11}{9.84,2.05}
\q{12.75,2.24}{12.87,2.32}{13.27,2.57}{13.13,2.48}
\q{10.36,1.87}{10.29,1.91}{10.77,1.84}{10.80,1.80}
\q{12.22,2.00}{12.31,2.05}{12.75,2.24}{12.63,2.17}
\q{11.25,1.79}{11.27,1.83}{11.76,1.88}{11.70,1.84}
\q{10.80,1.80}{10.77,1.84}{11.27,1.83}{11.25,1.79}
\q{9.84,2.05}{9.74,2.11}{10.22,1.96}{10.29,1.91}
\q{9.31,2.31}{9.19,2.40}{9.64,2.18}{9.74,2.11}
\q{11.76,1.88}{11.81,1.93}{12.31,2.05}{12.22,2.00}
\q{12.31,2.05}{12.39,2.12}{12.87,2.32}{12.75,2.24}
\q{10.29,1.91}{10.22,1.96}{10.74,1.88}{10.77,1.84}
\q{11.27,1.83}{11.28,1.87}{11.81,1.93}{11.76,1.88}
\q{10.77,1.84}{10.74,1.88}{11.28,1.87}{11.27,1.83}
\q{9.74,2.11}{9.64,2.18}{10.16,2.02}{10.22,1.96}
\q{11.81,1.93}{11.86,1.99}{12.39,2.12}{12.31,2.05}
\q{10.22,1.96}{10.16,2.02}{10.72,1.94}{10.74,1.88}
\q{11.28,1.87}{11.29,1.93}{11.86,1.99}{11.81,1.93}
\q{10.74,1.88}{10.72,1.94}{11.29,1.93}{11.28,1.87}
\draw[->] (0.00,1.58) -- (5.11,1.58) node[right] {$x$};
\draw[->] (2.45,0.00) -- (2.45,5.11) node[above] {$y$};
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.8s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (11.44,4.98) -- (10.60,3.80);\fill[hot] (11.44,4.98) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.1s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (10.60,3.80) -- (10.54,3.36);\fill[hot] (10.60,3.80) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.4s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (10.54,3.36) -- (10.62,3.09);\fill[hot] (10.54,3.36) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.7s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (10.62,3.09) -- (10.70,2.90);\fill[hot] (10.62,3.09) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (10.70,2.90) -- (10.78,2.76);\fill[hot] (10.70,2.90) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.3s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (10.78,2.76) -- (10.85,2.66);\fill[hot] (10.78,2.76) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.6s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (10.85,2.66) -- (10.90,2.58);\fill[hot] (10.85,2.66) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.9s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (10.90,2.58) -- (10.94,2.52);\fill[hot] (10.90,2.58) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.2s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (10.94,2.52) -- (10.97,2.48);\fill[hot] (10.94,2.52) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.5s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (10.97,2.48) -- (11.00,2.44);\fill[hot] (10.97,2.48) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.8s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (11.00,2.44) -- (11.02,2.42);\fill[hot] (11.00,2.44) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.1s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (11.02,2.42) -- (11.03,2.40);\fill[hot] (11.02,2.42) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.4s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (11.03,2.40) -- (11.05,2.38);\fill[hot] (11.03,2.40) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.7s = "true", 12.8s = "true", repeats}}}]
\draw[hot, thick] (11.05,2.38) -- (11.06,2.37);\fill[hot] (11.05,2.38) circle (1.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "true", 2.8s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (1.72,0.01) -- (4.90,4.71);
\draw[hot] (0.29,0.52) -- (0.29,0.00);
\draw[hot] (0.86,0.85) -- (0.86,0.00);
\draw[hot] (1.51,1.64) -- (1.51,0.00);
\draw[hot] (2.16,2.32) -- (2.16,0.66);
\draw[hot] (2.74,2.96) -- (2.74,1.51);
\draw[hot] (3.38,3.22) -- (3.38,2.47);
\draw[hot] (4.03,3.58) -- (4.03,3.43);
\draw[hot] (4.61,3.98) -- (4.61,4.28);
\filldraw[draw=black, fill=hot] (11.44,4.98) circle (3pt);\draw[thick] (11.44,4.98) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $0$: \ $\beta_0 = -0.69$, \ $\beta_1 = 1.48$, \ $\mathrm{MSE} = 4.96$};
\node[anchor=west] at (-0.2,-1.5) {Gradient descent starts on the rim of the bowl. The line is too steep and the MSE is high.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.8s = "true", 3.1s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (1.07,0.01) -- (4.90,3.72);
\draw[hot] (0.29,0.52) -- (0.29,0.00);
\draw[hot] (0.86,0.85) -- (0.86,0.00);
\draw[hot] (1.51,1.64) -- (1.51,0.44);
\draw[hot] (2.16,2.32) -- (2.16,1.07);
\draw[hot] (2.74,2.96) -- (2.74,1.63);
\draw[hot] (3.38,3.22) -- (3.38,2.25);
\draw[hot] (4.03,3.58) -- (4.03,2.88);
\draw[hot] (4.61,3.98) -- (4.61,3.44);
\filldraw[draw=black, fill=hot] (10.60,3.80) circle (3pt);\draw[thick] (10.60,3.80) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $1$: \ $\beta_0 = -0.33$, \ $\beta_1 = 0.97$, \ $\mathrm{MSE} = 2.21$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.1s = "true", 3.4s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.64,0.00) -- (4.90,3.65);
\draw[hot] (0.29,0.52) -- (0.29,0.00);
\draw[hot] (0.86,0.85) -- (0.86,0.19);
\draw[hot] (1.51,1.64) -- (1.51,0.75);
\draw[hot] (2.16,2.32) -- (2.16,1.31);
\draw[hot] (2.74,2.96) -- (2.74,1.80);
\draw[hot] (3.38,3.22) -- (3.38,2.36);
\draw[hot] (4.03,3.58) -- (4.03,2.91);
\draw[hot] (4.61,3.98) -- (4.61,3.41);
\filldraw[draw=black, fill=hot] (10.54,3.36) circle (3pt);\draw[thick] (10.54,3.36) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $2$: \ $\beta_0 = -0.04$, \ $\beta_1 = 0.86$, \ $\mathrm{MSE} = 1.39$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.4s = "true", 3.7s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.39,0.01) -- (4.90,3.76);
\draw[hot] (0.29,0.52) -- (0.29,0.00);
\draw[hot] (0.86,0.85) -- (0.86,0.40);
\draw[hot] (1.51,1.64) -- (1.51,0.94);
\draw[hot] (2.16,2.32) -- (2.16,1.48);
\draw[hot] (2.74,2.96) -- (2.74,1.96);
\draw[hot] (3.38,3.22) -- (3.38,2.50);
\draw[hot] (4.03,3.58) -- (4.03,3.04);
\draw[hot] (4.61,3.98) -- (4.61,3.52);
\filldraw[draw=black, fill=hot] (10.62,3.09) circle (3pt);\draw[thick] (10.62,3.09) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $3$: \ $\beta_0 = 0.19$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.91$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.7s = "true", 4s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.22,0.01) -- (4.90,3.88);
\draw[hot] (0.29,0.52) -- (0.29,0.06);
\draw[hot] (0.86,0.85) -- (0.86,0.54);
\draw[hot] (1.51,1.64) -- (1.51,1.08);
\draw[hot] (2.16,2.32) -- (2.16,1.61);
\draw[hot] (2.74,2.96) -- (2.74,2.09);
\draw[hot] (3.38,3.22) -- (3.38,2.63);
\draw[hot] (4.03,3.58) -- (4.03,3.17);
\draw[hot] (4.61,3.98) -- (4.61,3.64);
\filldraw[draw=black, fill=hot] (10.70,2.90) circle (3pt);\draw[thick] (10.70,2.90) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $4$: \ $\beta_0 = 0.37$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.61$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4s = "true", 4.3s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.09,0.00) -- (4.90,3.99);
\draw[hot] (0.29,0.52) -- (0.29,0.17);
\draw[hot] (0.86,0.85) -- (0.86,0.65);
\draw[hot] (1.51,1.64) -- (1.51,1.18);
\draw[hot] (2.16,2.32) -- (2.16,1.72);
\draw[hot] (2.74,2.96) -- (2.74,2.20);
\draw[hot] (3.38,3.22) -- (3.38,2.73);
\draw[hot] (4.03,3.58) -- (4.03,3.27);
\draw[hot] (4.61,3.98) -- (4.61,3.75);
\filldraw[draw=black, fill=hot] (10.78,2.76) circle (3pt);\draw[thick] (10.78,2.76) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $5$: \ $\beta_0 = 0.52$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.41$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.3s = "true", 4.6s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.00,0.02) -- (4.90,4.07);
\draw[hot] (0.29,0.52) -- (0.29,0.26);
\draw[hot] (1.51,1.64) -- (1.51,1.27);
\draw[hot] (2.16,2.32) -- (2.16,1.81);
\draw[hot] (2.74,2.96) -- (2.74,2.28);
\draw[hot] (3.38,3.22) -- (3.38,2.82);
\draw[hot] (4.03,3.58) -- (4.03,3.36);
\draw[hot] (4.61,3.98) -- (4.61,3.83);
\filldraw[draw=black, fill=hot] (10.85,2.66) circle (3pt);\draw[thick] (10.85,2.66) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $6$: \ $\beta_0 = 0.64$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.29$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.6s = "true", 4.9s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.00,0.09) -- (4.90,4.14);
\draw[hot] (0.29,0.52) -- (0.29,0.32);
\draw[hot] (1.51,1.64) -- (1.51,1.34);
\draw[hot] (2.16,2.32) -- (2.16,1.87);
\draw[hot] (2.74,2.96) -- (2.74,2.35);
\draw[hot] (3.38,3.22) -- (3.38,2.89);
\draw[hot] (4.03,3.58) -- (4.03,3.42);
\filldraw[draw=black, fill=hot] (10.90,2.58) circle (3pt);\draw[thick] (10.90,2.58) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $7$: \ $\beta_0 = 0.73$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.21$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.9s = "true", 5.2s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.00,0.14) -- (4.90,4.19);
\draw[hot] (0.29,0.52) -- (0.29,0.38);
\draw[hot] (1.51,1.64) -- (1.51,1.39);
\draw[hot] (2.16,2.32) -- (2.16,1.93);
\draw[hot] (2.74,2.96) -- (2.74,2.40);
\draw[hot] (3.38,3.22) -- (3.38,2.94);
\filldraw[draw=black, fill=hot] (10.94,2.52) circle (3pt);\draw[thick] (10.94,2.52) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $8$: \ $\beta_0 = 0.81$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.15$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.2s = "true", 5.5s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.00,0.18) -- (4.90,4.24);
\draw[hot] (1.51,1.64) -- (1.51,1.43);
\draw[hot] (2.16,2.32) -- (2.16,1.97);
\draw[hot] (2.74,2.96) -- (2.74,2.45);
\draw[hot] (3.38,3.22) -- (3.38,2.98);
\filldraw[draw=black, fill=hot] (10.97,2.48) circle (3pt);\draw[thick] (10.97,2.48) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $9$: \ $\beta_0 = 0.87$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.12$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.5s = "true", 5.8s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.00,0.22) -- (4.90,4.27);
\draw[hot] (1.51,1.64) -- (1.51,1.47);
\draw[hot] (2.16,2.32) -- (2.16,2.01);
\draw[hot] (2.74,2.96) -- (2.74,2.48);
\draw[hot] (3.38,3.22) -- (3.38,3.02);
\filldraw[draw=black, fill=hot] (11.00,2.44) circle (3pt);\draw[thick] (11.00,2.44) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $10$: \ $\beta_0 = 0.92$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.10$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.8s = "true", 6.1s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.00,0.25) -- (4.90,4.30);
\draw[hot] (1.51,1.64) -- (1.51,1.50);
\draw[hot] (2.16,2.32) -- (2.16,2.03);
\draw[hot] (2.74,2.96) -- (2.74,2.51);
\draw[hot] (3.38,3.22) -- (3.38,3.05);
\filldraw[draw=black, fill=hot] (11.02,2.42) circle (3pt);\draw[thick] (11.02,2.42) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $11$: \ $\beta_0 = 0.96$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.09$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.1s = "true", 6.4s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.00,0.27) -- (4.90,4.32);
\draw[hot] (0.86,0.85) -- (0.86,0.98);
\draw[hot] (2.16,2.32) -- (2.16,2.06);
\draw[hot] (2.74,2.96) -- (2.74,2.53);
\draw[hot] (3.38,3.22) -- (3.38,3.07);
\filldraw[draw=black, fill=hot] (11.03,2.40) circle (3pt);\draw[thick] (11.03,2.40) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $12$: \ $\beta_0 = 0.99$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.08$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.4s = "true", 6.7s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.00,0.29) -- (4.90,4.34);
\draw[hot] (0.86,0.85) -- (0.86,1.00);
\draw[hot] (2.16,2.32) -- (2.16,2.07);
\draw[hot] (2.74,2.96) -- (2.74,2.55);
\draw[hot] (3.38,3.22) -- (3.38,3.09);
\draw[hot] (4.61,3.98) -- (4.61,4.10);
\filldraw[draw=black, fill=hot] (11.05,2.38) circle (3pt);\draw[thick] (11.05,2.38) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $13$: \ $\beta_0 = 1.01$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.07$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.7s = "true", 7s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.00,0.30) -- (4.90,4.35);
\draw[hot] (0.86,0.85) -- (0.86,1.02);
\draw[hot] (2.16,2.32) -- (2.16,2.09);
\draw[hot] (2.74,2.96) -- (2.74,2.56);
\draw[hot] (3.38,3.22) -- (3.38,3.10);
\draw[hot] (4.61,3.98) -- (4.61,4.11);
\filldraw[draw=black, fill=hot] (11.06,2.37) circle (3pt);\draw[thick] (11.06,2.37) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $14$: \ $\beta_0 = 1.03$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.07$};
\node[anchor=west] at (-0.2,-1.5) {Each step moves $(\beta_0, \beta_1)$ against the gradient of the MSE, with $\eta = 0.1$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7s = "true", 9s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.00,0.30) -- (4.90,4.35);
\draw[hot] (0.86,0.85) -- (0.86,1.02);
\draw[hot] (2.16,2.32) -- (2.16,2.09);
\draw[hot] (2.74,2.96) -- (2.74,2.56);
\draw[hot] (3.38,3.22) -- (3.38,3.10);
\draw[hot] (4.61,3.98) -- (4.61,4.11);
\filldraw[draw=black, fill=hot] (11.06,2.37) circle (3pt);\draw[thick] (11.06,2.37) circle (5.5pt);
\node[anchor=west] at (-0.2,-0.75) {step $14$: \ $\beta_0 = 1.03$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.07$};
\node[anchor=west] at (-0.2,-1.5) {After $14$ steps the MSE has fallen from $4.96$ to $0.07$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 9s = "true", 12.8s = "false", 12.8s = "false", repeats}}}]
\draw[hot, very thick] (0.00,0.36) -- (4.90,4.41);
\draw[hot] (0.86,0.85) -- (0.86,1.07);
\draw[hot] (2.16,2.32) -- (2.16,2.15);
\draw[hot] (2.74,2.96) -- (2.74,2.62);
\draw[hot] (4.61,3.98) -- (4.61,4.17);
\filldraw[draw=black, fill=cold] (11.10,2.31) circle (3.4pt);
\node[anchor=west] at (-0.2,-0.75) {OLS minimum: \ $\beta_0 = 1.11$, \ $\beta_1 = 0.83$, \ $\mathrm{MSE} = 0.06$};
\node[anchor=west] at (-0.2,-1.5) {Blue: the OLS solution at the bottom of the bowl. Both partial derivatives of the MSE are zero there.};
\end{scope}
\pt{0.29,0.52}
\pt{0.86,0.85}
\pt{1.51,1.64}
\pt{2.16,2.32}
\pt{2.74,2.96}
\pt{3.38,3.22}
\pt{4.03,3.58}
\pt{4.61,3.98}
\end{tikzpicture}
\end{document}

Properties

(Offset Plus Spread) MSE equals the squared mean residual plus the variance of the residuals.

Write for the mean residual. Then

The first term measures a systematic offset, such as a price model that underpredicts every house by thousand dollars. The second term measures the scatter around that offset. Subtracting from every prediction removes the first term and leaves the second. OLS with an intercept sets on its training data, so its training MSE is pure spread. On new data the offset can return, for example after prices rise. For a parameter estimate , the same split reads (1.2.4 Minimum Mean Squared Error Estimation).

(Reading RMSE Against MAE) RMSE is never smaller than MAE, and the gap measures how uneven the errors are.

For any residuals, . The lower bound is reached when all are equal. The upper bound is reached when one residual carries all the error. For Gaussian residuals with mean zero and standard deviation , and . A ratio RMSE/MAE near is therefore typical of Gaussian noise. A ratio well above suggests a few large errors that deserve inspection.

(Large Residuals, Large Steps) Gradient descent on MSE takes steps that scale with the residuals.

For a linear model , the gradient of SSE is , where is the vector of residuals. At the same input, a point with residual pushes times harder than a point with residual . Near the optimum the residuals and the gradient shrink together, so gradient descent with a fixed learning rate settles smoothly. Far from the optimum, one huge residual can produce one huge step. Deep regression models with unbounded targets can then suffer exploding gradients. Huber loss caps the pull of each point to prevent this.

(Sensitivity to Outliers) One corrupted point can move the MSE-optimal prediction arbitrarily far.

The breakdown point of an estimator is the smallest fraction of corrupted points that can move it arbitrarily far. For the mean it is , since one corrupted value suffices, and it tends to as grows. The median has breakdown point . Least squares regression inherits the weakness of the mean, and one corrupted response can tilt the whole line. Squared error suits data where large errors are real and costly, such as peak loads on a power grid. It is a poor choice when large errors come from data-entry mistakes or sensor glitches.

(Averaging Over Modes) When the outcome has several likely values, the MSE-optimal prediction can fall between them.

The conditional mean is the best guess only in the squared-error sense. Suppose a route takes minutes without traffic and with traffic. The mean may then be a time that never occurs. Image models show the same effect. A colorization network trained with squared error averages the plausible colors of an object and outputs dull, grayish images (8.3. Image Colorization). One fix is to predict a full distribution. Others predict the median or another quantile, or add a loss that rewards realistic outputs.

Derivation

We show that the conditional mean minimizes the expected squared error. Fix an input and write . For any constant prediction , add and subtract inside the square:

The middle term vanishes because . The first term does not depend on , and the second is zero only at . The minimum expected loss is , the noise that no model can remove. The same steps with a sample average in place of the expectation give as the best constant.

For the Gaussian link, suppose with independent . The log-likelihood of the data is

For fixed , only the last sum depends on , so maximizing minimizes SSE. Setting gives , the training MSE. 3.1. Linear Regression carries out the same steps for the line . That note also gives the unbiased estimate, which divides SSE by the residual degrees of freedom.

Examples

(Easy) Scoring a House-Price Model

A model predicts the sale prices of five houses in thousands of dollars. The true prices are , and the predictions are .

(Medium) A Sensor Glitch

A thermometer in a stable room records degrees Celsius. A sixth reading of comes from a loose wire.

(Hard) Two Traffic Regimes

A delivery route takes minutes with probability and minutes with probability , depending on traffic. A model has no traffic information and must predict one number.

See Also