Mean Absolute Error

The mean absolute error (MAE) averages the absolute residuals of predictions:

Here is the true value, is the prediction and is the residual. The pointwise loss is the absolute error , also called the L1 loss. MAE is in the units of . Fitting a linear model by minimizing is called least absolute deviations (LAD) regression. MAE has five headline facts:

  • Minimizer: the best constant prediction is any sample median. Over all functions of , the population risk is minimized by the conditional median of given .
  • Laplace likelihood: suppose has the Laplace density with scale . The negative log-likelihood is . Minimizing MAE is then maximum likelihood, and the MLE of is the training MAE.
  • Subgradient: for . At the loss has a corner. Every value in is then a subgradient. A subgradient is the slope of a line through the corner that stays below the loss.
  • Robustness: every point pulls on the fit with the same strength, whatever the size of its residual. The median has breakdown point , so it stays bounded while fewer than half the values are corrupted.
  • No closed form: LAD regression is a linear program, solved by the simplex method, interior-point methods or iteratively reweighted least squares.

MAE is the robust alternative to MSE for data where outliers dominate or the median is wanted. Huber loss keeps most of its robustness and smooths the corner at zero.

Intuition

The name lists the steps. Take each error, drop its sign, and average. An error of costs ten times an error of , and no more. A model trained on MAE therefore rates one error of and ten errors of as equally bad. MAE is also easy to read. An MAE of minutes means the predictions miss by minutes on average.

The median appears for a counting reason. Move a constant prediction up by a small amount. Every point above loses that amount of error, and every point below gains it. The total falls while more points lie above than below. It stops falling where the two counts balance, and that point is the median. The size of each residual never enters this count. A data-entry error of a million dollars moves the median no more than a one-dollar error on the same side.

The animation moves a constant guess across seven values. MSE is lowest at the mean, and MAE is lowest at the median. When the largest value moves farther out, only the mean follows it.

\usepackage{tikz}
\usetikzlibrary{animations, arrows.meta}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\definecolor{mid}{HTML}{8A8A8A}
\newcommand{\pt}[1]{\filldraw[draw=black, fill=mid] (#1) circle (2.6pt);}
\begin{tikzpicture}[font=\small, >={Stealth[length=2.2mm]}]
\draw[->] (-0.2,8.5) -- (14.30,8.5) node[right] {$y$};
\draw (0.00,8.42) -- (0.00,8.58) node[pos=0, below] {\footnotesize $0$};
\draw (3.50,8.42) -- (3.50,8.58) node[pos=0, below] {\footnotesize $5$};
\draw (7.00,8.42) -- (7.00,8.58) node[pos=0, below] {\footnotesize $10$};
\draw (10.50,8.42) -- (10.50,8.58) node[pos=0, below] {\footnotesize $15$};
\draw (14.00,8.42) -- (14.00,8.58) node[pos=0, below] {\footnotesize $20$};
\draw[->] (0,4.5) -- (6.60,4.5) node[right] {$c$};
\draw[->] (0,4.5) -- (0,7.50);
\node[rotate=90] at (-0.85,5.85) {MSE$(c)$};
\draw (-0.08,5.33) -- (0.08,5.33) node[pos=0, left] {\footnotesize $20$};
\draw (-0.08,6.16) -- (0.08,6.16) node[pos=0, left] {\footnotesize $40$};
\draw (-0.08,6.99) -- (0.08,6.99) node[pos=0, left] {\footnotesize $60$};
\draw (0.00,4.42) -- (0.00,4.58) node[pos=0, below] {\footnotesize $0$};
\draw (2.10,4.42) -- (2.10,4.58) node[pos=0, below] {\footnotesize $3$};
\draw (4.20,4.42) -- (4.20,4.58) node[pos=0, below] {\footnotesize $6$};
\draw (6.30,4.42) -- (6.30,4.58) node[pos=0, below] {\footnotesize $9$};
\draw[->] (0,0.55) -- (6.60,0.55) node[right] {$c$};
\draw[->] (0,0.55) -- (0,3.55);
\node[rotate=90] at (-0.85,1.90) {MAE$(c)$};
\draw (-0.08,1.32) -- (0.08,1.32) node[pos=0, left] {\footnotesize $2$};
\draw (-0.08,2.09) -- (0.08,2.09) node[pos=0, left] {\footnotesize $4$};
\draw (-0.08,2.86) -- (0.08,2.86) node[pos=0, left] {\footnotesize $6$};
\draw (0.00,0.47) -- (0.00,0.63) node[pos=0, below] {\footnotesize $0$};
\draw (2.10,0.47) -- (2.10,0.63) node[pos=0, below] {\footnotesize $3$};
\draw (4.20,0.47) -- (4.20,0.63) node[pos=0, below] {\footnotesize $6$};
\draw (6.30,0.47) -- (6.30,0.63) node[pos=0, below] {\footnotesize $9$};
\node[anchor=west] at (7.2,6.50) {$\mathrm{MSE}(c) = \frac{1}{7}\sum_i (y_i - c)^2$};
\node[anchor=west] at (7.2,2.55) {$\mathrm{MAE}(c) = \frac{1}{7}\sum_i |y_i - c|$};
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.6s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (0.00,5.75) -- (0.17,5.66) -- (0.35,5.58) -- (0.52,5.51);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.6s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (0.00,2.20) -- (0.17,2.11) -- (0.35,2.01) -- (0.52,1.91);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.86s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (0.52,5.51) -- (0.70,5.43) -- (0.88,5.37) -- (1.05,5.31);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.86s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (0.52,1.91) -- (0.70,1.82) -- (0.88,1.75) -- (1.05,1.68);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.12s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (1.05,5.31) -- (1.22,5.25) -- (1.40,5.20) -- (1.57,5.16);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.12s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (1.05,1.68) -- (1.22,1.61) -- (1.40,1.54) -- (1.57,1.50);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.38s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (1.57,5.16) -- (1.75,5.12) -- (1.92,5.08) -- (2.10,5.05);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.38s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (1.57,1.50) -- (1.75,1.46) -- (1.92,1.45) -- (2.10,1.43);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.64s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (2.10,5.05) -- (2.27,5.03) -- (2.45,5.01) -- (2.62,5.00);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.64s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (2.10,1.43) -- (2.27,1.45) -- (2.45,1.46) -- (2.62,1.47);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.9s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (2.62,5.00) -- (2.80,4.99) -- (2.97,4.99) -- (3.15,4.99);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.9s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (2.62,1.47) -- (2.80,1.49) -- (2.97,1.53) -- (3.15,1.57);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.16s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (3.15,4.99) -- (3.32,5.00) -- (3.50,5.01) -- (3.67,5.02);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.16s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (3.15,1.57) -- (3.32,1.61) -- (3.50,1.65) -- (3.67,1.69);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.42s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (3.67,5.02) -- (3.85,5.05) -- (4.02,5.08) -- (4.20,5.11);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.42s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (3.67,1.69) -- (3.85,1.73) -- (4.02,1.80) -- (4.20,1.87);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.68s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (4.20,5.11) -- (4.38,5.15) -- (4.55,5.19) -- (4.72,5.24);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.68s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (4.20,1.87) -- (4.38,1.94) -- (4.55,2.01) -- (4.72,2.08);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.94s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (4.72,5.24) -- (4.90,5.29) -- (5.07,5.35) -- (5.25,5.42);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.94s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (4.72,2.08) -- (4.90,2.15) -- (5.07,2.22) -- (5.25,2.29);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.2s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (5.25,5.42) -- (5.42,5.48) -- (5.60,5.56) -- (5.77,5.64);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.2s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (5.25,2.29) -- (5.42,2.35) -- (5.60,2.42) -- (5.77,2.49);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.46s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (5.77,5.64) -- (5.95,5.72) -- (6.12,5.81) -- (6.30,5.91);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.46s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[cold, very thick] (5.77,2.49) -- (5.95,2.56) -- (6.12,2.63) -- (6.30,2.70);
\end{scope}
\begin{scope}[]
\pt{0.70,8.5}
\pt{1.40,8.5}
\pt{1.75,8.5}
\pt{2.10,8.5}
\pt{2.80,8.5}
\pt{3.85,8.5}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\pt{8.40,8.5}
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.72s = "true", 14.12s = "true", repeats}}}]
\draw[hot, dashed] (0.00,5.75) -- (0.17,5.66) -- (0.35,5.58) -- (0.52,5.51) -- (0.70,5.43) -- (0.88,5.37) -- (1.05,5.31) -- (1.22,5.25) -- (1.40,5.20) -- (1.57,5.16) -- (1.75,5.12) -- (1.92,5.08) -- (2.10,5.05) -- (2.27,5.03) -- (2.45,5.01) -- (2.62,5.00) -- (2.80,4.99) -- (2.97,4.99) -- (3.15,4.99) -- (3.32,5.00) -- (3.50,5.01) -- (3.67,5.02) -- (3.85,5.05) -- (4.02,5.08) -- (4.20,5.11) -- (4.38,5.15) -- (4.55,5.19) -- (4.72,5.24) -- (4.90,5.29) -- (5.07,5.35) -- (5.25,5.42) -- (5.42,5.48) -- (5.60,5.56) -- (5.77,5.64) -- (5.95,5.72) -- (6.12,5.81) -- (6.30,5.91);
\draw[cold, dashed] (0.00,2.20) -- (0.17,2.11) -- (0.35,2.01) -- (0.52,1.91) -- (0.70,1.82) -- (0.88,1.75) -- (1.05,1.68) -- (1.22,1.61) -- (1.40,1.54) -- (1.57,1.50) -- (1.75,1.46) -- (1.92,1.45) -- (2.10,1.43) -- (2.27,1.45) -- (2.45,1.46) -- (2.62,1.47) -- (2.80,1.49) -- (2.97,1.53) -- (3.15,1.57) -- (3.32,1.61) -- (3.50,1.65) -- (3.67,1.69) -- (3.85,1.73) -- (4.02,1.80) -- (4.20,1.87) -- (4.38,1.94) -- (4.55,2.01) -- (4.72,2.08) -- (4.90,2.15) -- (5.07,2.22) -- (5.25,2.29) -- (5.42,2.35) -- (5.60,2.42) -- (5.77,2.49) -- (5.95,2.56) -- (6.12,2.63) -- (6.30,2.70);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.72s = "true", 14.12s = "true", repeats}}}]
\draw[mid, thick] (8.40,8.5) circle (2.6pt);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "true", 2.6s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (0.00,8.50) -- (0.00,8.95);
\draw[dashed] (0.00,4.50) -- (0.00,7.20);
\draw[dashed] (0.00,0.55) -- (0.00,3.25);
\node[anchor=south] at (0.00,8.95) {$c$};
\filldraw[draw=black, fill=hot] (0.00,5.75) circle (2.4pt);
\filldraw[draw=black, fill=cold] (0.00,2.20) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 0.00$: \ $\mathrm{MSE} = 30.07$};
\node[anchor=west] at (7.2,1.70) {at $c = 0.00$: \ $\mathrm{MAE} = 4.29$};
\node[anchor=west] at (-0.6,-0.75) {Seven values and one constant guess $c$. Each curve scores $c$ against all seven values.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.6s = "true", 2.86s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (0.52,8.50) -- (0.52,8.95);
\draw[dashed] (0.52,4.50) -- (0.52,7.20);
\draw[dashed] (0.52,0.55) -- (0.52,3.25);
\node[anchor=south] at (0.52,8.95) {$c$};
\filldraw[draw=black, fill=hot] (0.52,5.51) circle (2.4pt);
\filldraw[draw=black, fill=cold] (0.52,1.91) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 0.75$: \ $\mathrm{MSE} = 24.21$};
\node[anchor=west] at (7.2,1.70) {at $c = 0.75$: \ $\mathrm{MAE} = 3.54$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.86s = "true", 3.12s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (1.05,8.50) -- (1.05,8.95);
\draw[dashed] (1.05,4.50) -- (1.05,7.20);
\draw[dashed] (1.05,0.55) -- (1.05,3.25);
\node[anchor=south] at (1.05,8.95) {$c$};
\filldraw[draw=black, fill=hot] (1.05,5.31) circle (2.4pt);
\filldraw[draw=black, fill=cold] (1.05,1.68) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 1.50$: \ $\mathrm{MSE} = 19.46$};
\node[anchor=west] at (7.2,1.70) {at $c = 1.50$: \ $\mathrm{MAE} = 2.93$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.12s = "true", 3.38s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (1.57,8.50) -- (1.57,8.95);
\draw[dashed] (1.57,4.50) -- (1.57,7.20);
\draw[dashed] (1.57,0.55) -- (1.57,3.25);
\node[anchor=south] at (1.57,8.95) {$c$};
\filldraw[draw=black, fill=hot] (1.57,5.16) circle (2.4pt);
\filldraw[draw=black, fill=cold] (1.57,1.50) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 2.25$: \ $\mathrm{MSE} = 15.85$};
\node[anchor=west] at (7.2,1.70) {at $c = 2.25$: \ $\mathrm{MAE} = 2.46$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.38s = "true", 3.64s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (2.10,8.50) -- (2.10,8.95);
\draw[dashed] (2.10,4.50) -- (2.10,7.20);
\draw[dashed] (2.10,0.55) -- (2.10,3.25);
\node[anchor=south] at (2.10,8.95) {$c$};
\filldraw[draw=black, fill=hot] (2.10,5.05) circle (2.4pt);
\filldraw[draw=black, fill=cold] (2.10,1.43) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 3.00$: \ $\mathrm{MSE} = 13.36$};
\node[anchor=west] at (7.2,1.70) {at $c = 3.00$: \ $\mathrm{MAE} = 2.29$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.64s = "true", 3.9s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (2.62,8.50) -- (2.62,8.95);
\draw[dashed] (2.62,4.50) -- (2.62,7.20);
\draw[dashed] (2.62,0.55) -- (2.62,3.25);
\node[anchor=south] at (2.62,8.95) {$c$};
\filldraw[draw=black, fill=hot] (2.62,5.00) circle (2.4pt);
\filldraw[draw=black, fill=cold] (2.62,1.47) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 3.75$: \ $\mathrm{MSE} = 11.99$};
\node[anchor=west] at (7.2,1.70) {at $c = 3.75$: \ $\mathrm{MAE} = 2.39$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.9s = "true", 4.16s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (3.15,8.50) -- (3.15,8.95);
\draw[dashed] (3.15,4.50) -- (3.15,7.20);
\draw[dashed] (3.15,0.55) -- (3.15,3.25);
\node[anchor=south] at (3.15,8.95) {$c$};
\filldraw[draw=black, fill=hot] (3.15,4.99) circle (2.4pt);
\filldraw[draw=black, fill=cold] (3.15,1.57) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 4.50$: \ $\mathrm{MSE} = 11.75$};
\node[anchor=west] at (7.2,1.70) {at $c = 4.50$: \ $\mathrm{MAE} = 2.64$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.16s = "true", 4.42s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (3.67,8.50) -- (3.67,8.95);
\draw[dashed] (3.67,4.50) -- (3.67,7.20);
\draw[dashed] (3.67,0.55) -- (3.67,3.25);
\node[anchor=south] at (3.67,8.95) {$c$};
\filldraw[draw=black, fill=hot] (3.67,5.02) circle (2.4pt);
\filldraw[draw=black, fill=cold] (3.67,1.69) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 5.25$: \ $\mathrm{MSE} = 12.63$};
\node[anchor=west] at (7.2,1.70) {at $c = 5.25$: \ $\mathrm{MAE} = 2.96$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.42s = "true", 4.68s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (4.20,8.50) -- (4.20,8.95);
\draw[dashed] (4.20,4.50) -- (4.20,7.20);
\draw[dashed] (4.20,0.55) -- (4.20,3.25);
\node[anchor=south] at (4.20,8.95) {$c$};
\filldraw[draw=black, fill=hot] (4.20,5.11) circle (2.4pt);
\filldraw[draw=black, fill=cold] (4.20,1.87) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 6.00$: \ $\mathrm{MSE} = 14.64$};
\node[anchor=west] at (7.2,1.70) {at $c = 6.00$: \ $\mathrm{MAE} = 3.43$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.68s = "true", 4.94s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (4.72,8.50) -- (4.72,8.95);
\draw[dashed] (4.72,4.50) -- (4.72,7.20);
\draw[dashed] (4.72,0.55) -- (4.72,3.25);
\node[anchor=south] at (4.72,8.95) {$c$};
\filldraw[draw=black, fill=hot] (4.72,5.24) circle (2.4pt);
\filldraw[draw=black, fill=cold] (4.72,2.08) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 6.75$: \ $\mathrm{MSE} = 17.78$};
\node[anchor=west] at (7.2,1.70) {at $c = 6.75$: \ $\mathrm{MAE} = 3.96$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 4.94s = "true", 5.2s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (5.25,8.50) -- (5.25,8.95);
\draw[dashed] (5.25,4.50) -- (5.25,7.20);
\draw[dashed] (5.25,0.55) -- (5.25,3.25);
\node[anchor=south] at (5.25,8.95) {$c$};
\filldraw[draw=black, fill=hot] (5.25,5.42) circle (2.4pt);
\filldraw[draw=black, fill=cold] (5.25,2.29) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 7.50$: \ $\mathrm{MSE} = 22.04$};
\node[anchor=west] at (7.2,1.70) {at $c = 7.50$: \ $\mathrm{MAE} = 4.50$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.2s = "true", 5.46s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (5.77,8.50) -- (5.77,8.95);
\draw[dashed] (5.77,4.50) -- (5.77,7.20);
\draw[dashed] (5.77,0.55) -- (5.77,3.25);
\node[anchor=south] at (5.77,8.95) {$c$};
\filldraw[draw=black, fill=hot] (5.77,5.64) circle (2.4pt);
\filldraw[draw=black, fill=cold] (5.77,2.49) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 8.25$: \ $\mathrm{MSE} = 27.42$};
\node[anchor=west] at (7.2,1.70) {at $c = 8.25$: \ $\mathrm{MAE} = 5.04$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.46s = "true", 5.72s = "false", 14.12s = "false", repeats}}}]
\draw[dashed] (6.30,8.50) -- (6.30,8.95);
\draw[dashed] (6.30,4.50) -- (6.30,7.20);
\draw[dashed] (6.30,0.55) -- (6.30,3.25);
\node[anchor=south] at (6.30,8.95) {$c$};
\filldraw[draw=black, fill=hot] (6.30,5.91) circle (2.4pt);
\filldraw[draw=black, fill=cold] (6.30,2.70) circle (2.4pt);
\node[anchor=west] at (7.2,5.65) {at $c = 9.00$: \ $\mathrm{MSE} = 33.93$};
\node[anchor=west] at (7.2,1.70) {at $c = 9.00$: \ $\mathrm{MAE} = 5.57$};
\node[anchor=west] at (-0.6,-0.75) {The guess $c$ moves right. Both curves are traced as it moves.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.72s = "true", 8.72s = "false", 14.12s = "false", repeats}}}]
\draw[hot, dashed] (3.00,4.50) -- (3.00,4.99);
\draw[cold, dashed] (2.10,0.55) -- (2.10,1.43);
\filldraw[draw=black, fill=hot] (3.00,4.99) circle (3pt);
\filldraw[draw=black, fill=cold] (2.10,1.43) circle (3pt);
\filldraw[draw=black, fill=hot] (3.00,8.63) -- ++(-0.13,0.24) -- ++(0.26,0) -- cycle;
\node[anchor=south] at (3.00,8.90) {\footnotesize mean};
\filldraw[draw=black, fill=cold] (2.10,8.37) -- ++(-0.13,-0.24) -- ++(0.26,0) -- cycle;
\node[anchor=north] at (2.10,8.10) {\footnotesize median};
\node[anchor=west] at (7.2,5.65) {lowest at $c = \bar y = 4.29$, \ $\mathrm{MSE} = 11.70$};
\node[anchor=west] at (7.2,1.70) {lowest at $c = \mathrm{median} = 3$, \ $\mathrm{MAE} = 2.29$};
\node[anchor=west] at (-0.6,-0.75) {MSE is lowest at the mean, $4.29$. MAE is lowest at the median, $3$.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.72s = "true", 9.02s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (0.00,5.90) -- (0.17,5.81) -- (0.35,5.72) -- (0.52,5.64) -- (0.70,5.57) -- (0.88,5.50) -- (1.05,5.44) -- (1.22,5.38) -- (1.40,5.33) -- (1.57,5.28) -- (1.75,5.24) -- (1.92,5.20) -- (2.10,5.17) -- (2.27,5.14) -- (2.45,5.12) -- (2.62,5.10) -- (2.80,5.09) -- (2.97,5.08) -- (3.15,5.08) -- (3.32,5.09) -- (3.50,5.10) -- (3.67,5.11) -- (3.85,5.13) -- (4.02,5.16) -- (4.20,5.19) -- (4.38,5.22) -- (4.55,5.26) -- (4.72,5.31) -- (4.90,5.36) -- (5.07,5.41) -- (5.25,5.47) -- (5.42,5.54) -- (5.60,5.61) -- (5.77,5.69) -- (5.95,5.77) -- (6.12,5.86) -- (6.30,5.95);
\draw[cold, very thick] (0.00,2.26) -- (0.17,2.16) -- (0.35,2.07) -- (0.52,1.97) -- (0.70,1.87) -- (0.88,1.80) -- (1.05,1.73) -- (1.22,1.67) -- (1.40,1.60) -- (1.57,1.56) -- (1.75,1.51) -- (1.92,1.50) -- (2.10,1.49) -- (2.27,1.50) -- (2.45,1.51) -- (2.62,1.53) -- (2.80,1.54) -- (2.97,1.58) -- (3.15,1.62) -- (3.32,1.67) -- (3.50,1.71) -- (3.67,1.75) -- (3.85,1.79) -- (4.02,1.86) -- (4.20,1.93) -- (4.38,2.00) -- (4.55,2.07) -- (4.72,2.13) -- (4.90,2.20) -- (5.07,2.27) -- (5.25,2.34) -- (5.42,2.41) -- (5.60,2.48) -- (5.77,2.55) -- (5.95,2.62) -- (6.12,2.69) -- (6.30,2.75);
\draw[hot, dashed] (3.10,4.50) -- (3.10,5.08);
\draw[cold, dashed] (2.10,0.55) -- (2.10,1.49);
\filldraw[draw=black, fill=hot] (3.10,5.08) circle (3pt);
\filldraw[draw=black, fill=cold] (2.10,1.49) circle (3pt);
\filldraw[draw=black, fill=hot] (3.10,8.63) -- ++(-0.13,0.24) -- ++(0.26,0) -- cycle;
\node[anchor=south] at (3.10,8.90) {\footnotesize mean};
\filldraw[draw=black, fill=cold] (2.10,8.37) -- ++(-0.13,-0.24) -- ++(0.26,0) -- cycle;
\node[anchor=north] at (2.10,8.10) {\footnotesize median};
\node[anchor=west] at (7.2,5.65) {lowest at $c = \bar y = 4.43$, \ $\mathrm{MSE} = 14.03$};
\node[anchor=west] at (7.2,1.70) {lowest at $c = \mathrm{median} = 3$, \ $\mathrm{MAE} = 2.43$};
\pt{9.10,8.5}
\node[anchor=west] at (-0.6,-0.75) {The largest value moves from $12$ to $19$. The curves are recomputed.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 9.02s = "true", 9.32s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (0.00,6.06) -- (0.17,5.97) -- (0.35,5.88) -- (0.52,5.80) -- (0.70,5.72) -- (0.88,5.65) -- (1.05,5.58) -- (1.22,5.52) -- (1.40,5.46) -- (1.57,5.41) -- (1.75,5.37) -- (1.92,5.33) -- (2.10,5.29) -- (2.27,5.26) -- (2.45,5.24) -- (2.62,5.22) -- (2.80,5.20) -- (2.97,5.19) -- (3.15,5.19) -- (3.32,5.19) -- (3.50,5.20) -- (3.67,5.21) -- (3.85,5.23) -- (4.02,5.25) -- (4.20,5.27) -- (4.38,5.31) -- (4.55,5.34) -- (4.72,5.39) -- (4.90,5.43) -- (5.07,5.49) -- (5.25,5.55) -- (5.42,5.61) -- (5.60,5.68) -- (5.77,5.75) -- (5.95,5.83) -- (6.12,5.91) -- (6.30,6.00);
\draw[cold, very thick] (0.00,2.31) -- (0.17,2.22) -- (0.35,2.12) -- (0.52,2.02) -- (0.70,1.93) -- (0.88,1.86) -- (1.05,1.79) -- (1.22,1.72) -- (1.40,1.65) -- (1.57,1.61) -- (1.75,1.57) -- (1.92,1.56) -- (2.10,1.54) -- (2.27,1.56) -- (2.45,1.57) -- (2.62,1.58) -- (2.80,1.60) -- (2.97,1.64) -- (3.15,1.68) -- (3.32,1.72) -- (3.50,1.76) -- (3.67,1.80) -- (3.85,1.84) -- (4.02,1.91) -- (4.20,1.98) -- (4.38,2.05) -- (4.55,2.12) -- (4.72,2.19) -- (4.90,2.26) -- (5.07,2.33) -- (5.25,2.40) -- (5.42,2.46) -- (5.60,2.53) -- (5.77,2.60) -- (5.95,2.67) -- (6.12,2.74) -- (6.30,2.81);
\draw[hot, dashed] (3.20,4.50) -- (3.20,5.19);
\draw[cold, dashed] (2.10,0.55) -- (2.10,1.54);
\filldraw[draw=black, fill=hot] (3.20,5.19) circle (3pt);
\filldraw[draw=black, fill=cold] (2.10,1.54) circle (3pt);
\filldraw[draw=black, fill=hot] (3.20,8.63) -- ++(-0.13,0.24) -- ++(0.26,0) -- cycle;
\node[anchor=south] at (3.20,8.90) {\footnotesize mean};
\filldraw[draw=black, fill=cold] (2.10,8.37) -- ++(-0.13,-0.24) -- ++(0.26,0) -- cycle;
\node[anchor=north] at (2.10,8.10) {\footnotesize median};
\node[anchor=west] at (7.2,5.65) {lowest at $c = \bar y = 4.57$, \ $\mathrm{MSE} = 16.60$};
\node[anchor=west] at (7.2,1.70) {lowest at $c = \mathrm{median} = 3$, \ $\mathrm{MAE} = 2.57$};
\pt{9.80,8.5}
\node[anchor=west] at (-0.6,-0.75) {The largest value moves from $12$ to $19$. The curves are recomputed.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 9.32s = "true", 9.62s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (0.00,6.23) -- (0.17,6.13) -- (0.35,6.04) -- (0.52,5.96) -- (0.70,5.88) -- (0.88,5.81) -- (1.05,5.74) -- (1.22,5.67) -- (1.40,5.61) -- (1.57,5.56) -- (1.75,5.51) -- (1.92,5.47) -- (2.10,5.43) -- (2.27,5.40) -- (2.45,5.37) -- (2.62,5.35) -- (2.80,5.33) -- (2.97,5.32) -- (3.15,5.31) -- (3.32,5.31) -- (3.50,5.31) -- (3.67,5.32) -- (3.85,5.33) -- (4.02,5.35) -- (4.20,5.38) -- (4.38,5.40) -- (4.55,5.44) -- (4.72,5.48) -- (4.90,5.52) -- (5.07,5.57) -- (5.25,5.63) -- (5.42,5.69) -- (5.60,5.76) -- (5.77,5.83) -- (5.95,5.90) -- (6.12,5.98) -- (6.30,6.07);
\draw[cold, very thick] (0.00,2.37) -- (0.17,2.27) -- (0.35,2.18) -- (0.52,2.08) -- (0.70,1.98) -- (0.88,1.91) -- (1.05,1.84) -- (1.22,1.78) -- (1.40,1.71) -- (1.57,1.67) -- (1.75,1.62) -- (1.92,1.61) -- (2.10,1.60) -- (2.27,1.61) -- (2.45,1.62) -- (2.62,1.64) -- (2.80,1.65) -- (2.97,1.69) -- (3.15,1.73) -- (3.32,1.78) -- (3.50,1.82) -- (3.67,1.86) -- (3.85,1.90) -- (4.02,1.97) -- (4.20,2.04) -- (4.38,2.11) -- (4.55,2.18) -- (4.72,2.24) -- (4.90,2.31) -- (5.07,2.38) -- (5.25,2.45) -- (5.42,2.52) -- (5.60,2.59) -- (5.77,2.66) -- (5.95,2.73) -- (6.12,2.80) -- (6.30,2.86);
\draw[hot, dashed] (3.30,4.50) -- (3.30,5.31);
\draw[cold, dashed] (2.10,0.55) -- (2.10,1.60);
\filldraw[draw=black, fill=hot] (3.30,5.31) circle (3pt);
\filldraw[draw=black, fill=cold] (2.10,1.60) circle (3pt);
\filldraw[draw=black, fill=hot] (3.30,8.63) -- ++(-0.13,0.24) -- ++(0.26,0) -- cycle;
\node[anchor=south] at (3.30,8.90) {\footnotesize mean};
\filldraw[draw=black, fill=cold] (2.10,8.37) -- ++(-0.13,-0.24) -- ++(0.26,0) -- cycle;
\node[anchor=north] at (2.10,8.10) {\footnotesize median};
\node[anchor=west] at (7.2,5.65) {lowest at $c = \bar y = 4.71$, \ $\mathrm{MSE} = 19.42$};
\node[anchor=west] at (7.2,1.70) {lowest at $c = \mathrm{median} = 3$, \ $\mathrm{MAE} = 2.71$};
\pt{10.50,8.5}
\node[anchor=west] at (-0.6,-0.75) {The largest value moves from $12$ to $19$. The curves are recomputed.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 9.62s = "true", 9.92s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (0.00,6.41) -- (0.17,6.32) -- (0.35,6.22) -- (0.52,6.13) -- (0.70,6.05) -- (0.88,5.97) -- (1.05,5.90) -- (1.22,5.83) -- (1.40,5.77) -- (1.57,5.72) -- (1.75,5.66) -- (1.92,5.62) -- (2.10,5.58) -- (2.27,5.54) -- (2.45,5.51) -- (2.62,5.48) -- (2.80,5.46) -- (2.97,5.45) -- (3.15,5.44) -- (3.32,5.43) -- (3.50,5.43) -- (3.67,5.44) -- (3.85,5.45) -- (4.02,5.47) -- (4.20,5.49) -- (4.38,5.51) -- (4.55,5.55) -- (4.72,5.58) -- (4.90,5.62) -- (5.07,5.67) -- (5.25,5.72) -- (5.42,5.78) -- (5.60,5.84) -- (5.77,5.91) -- (5.95,5.99) -- (6.12,6.06) -- (6.30,6.15);
\draw[cold, very thick] (0.00,2.42) -- (0.17,2.33) -- (0.35,2.23) -- (0.52,2.13) -- (0.70,2.04) -- (0.88,1.97) -- (1.05,1.90) -- (1.22,1.83) -- (1.40,1.76) -- (1.57,1.72) -- (1.75,1.68) -- (1.92,1.67) -- (2.10,1.65) -- (2.27,1.67) -- (2.45,1.68) -- (2.62,1.69) -- (2.80,1.71) -- (2.97,1.75) -- (3.15,1.79) -- (3.32,1.83) -- (3.50,1.87) -- (3.67,1.91) -- (3.85,1.96) -- (4.02,2.02) -- (4.20,2.09) -- (4.38,2.16) -- (4.55,2.23) -- (4.72,2.30) -- (4.90,2.37) -- (5.07,2.44) -- (5.25,2.51) -- (5.42,2.58) -- (5.60,2.64) -- (5.77,2.71) -- (5.95,2.78) -- (6.12,2.85) -- (6.30,2.92);
\draw[hot, dashed] (3.40,4.50) -- (3.40,5.43);
\draw[cold, dashed] (2.10,0.55) -- (2.10,1.65);
\filldraw[draw=black, fill=hot] (3.40,5.43) circle (3pt);
\filldraw[draw=black, fill=cold] (2.10,1.65) circle (3pt);
\filldraw[draw=black, fill=hot] (3.40,8.63) -- ++(-0.13,0.24) -- ++(0.26,0) -- cycle;
\node[anchor=south] at (3.40,8.90) {\footnotesize mean};
\filldraw[draw=black, fill=cold] (2.10,8.37) -- ++(-0.13,-0.24) -- ++(0.26,0) -- cycle;
\node[anchor=north] at (2.10,8.10) {\footnotesize median};
\node[anchor=west] at (7.2,5.65) {lowest at $c = \bar y = 4.86$, \ $\mathrm{MSE} = 22.48$};
\node[anchor=west] at (7.2,1.70) {lowest at $c = \mathrm{median} = 3$, \ $\mathrm{MAE} = 2.86$};
\pt{11.20,8.5}
\node[anchor=west] at (-0.6,-0.75) {The largest value moves from $12$ to $19$. The curves are recomputed.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 9.92s = "true", 10.22s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (0.00,6.61) -- (0.17,6.51) -- (0.35,6.41) -- (0.52,6.32) -- (0.70,6.24) -- (0.88,6.16) -- (1.05,6.08) -- (1.22,6.01) -- (1.40,5.94) -- (1.57,5.89) -- (1.75,5.83) -- (1.92,5.78) -- (2.10,5.74) -- (2.27,5.70) -- (2.45,5.66) -- (2.62,5.64) -- (2.80,5.61) -- (2.97,5.59) -- (3.15,5.58) -- (3.32,5.57) -- (3.50,5.57) -- (3.67,5.57) -- (3.85,5.58) -- (4.02,5.59) -- (4.20,5.61) -- (4.38,5.64) -- (4.55,5.66) -- (4.72,5.70) -- (4.90,5.74) -- (5.07,5.78) -- (5.25,5.83) -- (5.42,5.89) -- (5.60,5.94) -- (5.77,6.01) -- (5.95,6.08) -- (6.12,6.16) -- (6.30,6.24);
\draw[cold, very thick] (0.00,2.48) -- (0.17,2.38) -- (0.35,2.29) -- (0.52,2.19) -- (0.70,2.09) -- (0.88,2.02) -- (1.05,1.96) -- (1.22,1.89) -- (1.40,1.82) -- (1.57,1.78) -- (1.75,1.73) -- (1.92,1.72) -- (2.10,1.71) -- (2.27,1.72) -- (2.45,1.73) -- (2.62,1.75) -- (2.80,1.76) -- (2.97,1.80) -- (3.15,1.84) -- (3.32,1.89) -- (3.50,1.93) -- (3.67,1.97) -- (3.85,2.01) -- (4.02,2.08) -- (4.20,2.15) -- (4.38,2.22) -- (4.55,2.29) -- (4.72,2.35) -- (4.90,2.42) -- (5.07,2.49) -- (5.25,2.56) -- (5.42,2.63) -- (5.60,2.70) -- (5.77,2.77) -- (5.95,2.84) -- (6.12,2.91) -- (6.30,2.97);
\draw[hot, dashed] (3.50,4.50) -- (3.50,5.57);
\draw[cold, dashed] (2.10,0.55) -- (2.10,1.71);
\filldraw[draw=black, fill=hot] (3.50,5.57) circle (3pt);
\filldraw[draw=black, fill=cold] (2.10,1.71) circle (3pt);
\filldraw[draw=black, fill=hot] (3.50,8.63) -- ++(-0.13,0.24) -- ++(0.26,0) -- cycle;
\node[anchor=south] at (3.50,8.90) {\footnotesize mean};
\filldraw[draw=black, fill=cold] (2.10,8.37) -- ++(-0.13,-0.24) -- ++(0.26,0) -- cycle;
\node[anchor=north] at (2.10,8.10) {\footnotesize median};
\node[anchor=west] at (7.2,5.65) {lowest at $c = \bar y = 5.00$, \ $\mathrm{MSE} = 25.79$};
\node[anchor=west] at (7.2,1.70) {lowest at $c = \mathrm{median} = 3$, \ $\mathrm{MAE} = 3.00$};
\pt{11.90,8.5}
\node[anchor=west] at (-0.6,-0.75) {The largest value moves from $12$ to $19$. The curves are recomputed.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 10.22s = "true", 10.52s = "false", 14.12s = "false", repeats}}}]
\draw[hot, very thick] (0.00,6.82) -- (0.17,6.71) -- (0.35,6.61) -- (0.52,6.52) -- (0.70,6.43) -- (0.88,6.35) -- (1.05,6.27) -- (1.22,6.20) -- (1.40,6.13) -- (1.57,6.07) -- (1.75,6.01) -- (1.92,5.96) -- (2.10,5.91) -- (2.27,5.87) -- (2.45,5.83) -- (2.62,5.80) -- (2.80,5.77) -- (2.97,5.75) -- (3.15,5.74) -- (3.32,5.73) -- (3.50,5.72) -- (3.67,5.72) -- (3.85,5.72) -- (4.02,5.73) -- (4.20,5.75) -- (4.38,5.77) -- (4.55,5.80) -- (4.72,5.83) -- (4.90,5.86) -- (5.07,5.90) -- (5.25,5.95) -- (5.42,6.00) -- (5.60,6.06) -- (5.77,6.12) -- (5.95,6.19) -- (6.12,6.26) -- (6.30,6.34);
\draw[cold, very thick] (0.00,2.53) -- (0.17,2.44) -- (0.35,2.34) -- (0.52,2.24) -- (0.70,2.15) -- (0.88,2.08) -- (1.05,2.01) -- (1.22,1.94) -- (1.40,1.87) -- (1.57,1.83) -- (1.75,1.79) -- (1.92,1.78) -- (2.10,1.76) -- (2.27,1.78) -- (2.45,1.79) -- (2.62,1.80) -- (2.80,1.82) -- (2.97,1.86) -- (3.15,1.90) -- (3.32,1.94) -- (3.50,1.98) -- (3.67,2.02) -- (3.85,2.07) -- (4.02,2.13) -- (4.20,2.20) -- (4.38,2.27) -- (4.55,2.34) -- (4.72,2.41) -- (4.90,2.48) -- (5.07,2.55) -- (5.25,2.62) -- (5.42,2.69) -- (5.60,2.75) -- (5.77,2.82) -- (5.95,2.89) -- (6.12,2.96) -- (6.30,3.03);
\draw[hot, dashed] (3.60,4.50) -- (3.60,5.72);
\draw[cold, dashed] (2.10,0.55) -- (2.10,1.76);
\filldraw[draw=black, fill=hot] (3.60,5.72) circle (3pt);
\filldraw[draw=black, fill=cold] (2.10,1.76) circle (3pt);
\filldraw[draw=black, fill=hot] (3.60,8.63) -- ++(-0.13,0.24) -- ++(0.26,0) -- cycle;
\node[anchor=south] at (3.60,8.90) {\footnotesize mean};
\filldraw[draw=black, fill=cold] (2.10,8.37) -- ++(-0.13,-0.24) -- ++(0.26,0) -- cycle;
\node[anchor=north] at (2.10,8.10) {\footnotesize median};
\node[anchor=west] at (7.2,5.65) {lowest at $c = \bar y = 5.14$, \ $\mathrm{MSE} = 29.34$};
\node[anchor=west] at (7.2,1.70) {lowest at $c = \mathrm{median} = 3$, \ $\mathrm{MAE} = 3.14$};
\pt{12.60,8.5}
\node[anchor=west] at (-0.6,-0.75) {The largest value moves from $12$ to $19$. The curves are recomputed.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 10.52s = "true", 14.12s = "true", repeats}}}]
\draw[hot, very thick] (0.00,7.04) -- (0.17,6.93) -- (0.35,6.83) -- (0.52,6.73) -- (0.70,6.64) -- (0.88,6.55) -- (1.05,6.47) -- (1.22,6.40) -- (1.40,6.32) -- (1.57,6.26) -- (1.75,6.20) -- (1.92,6.14) -- (2.10,6.09) -- (2.27,6.05) -- (2.45,6.01) -- (2.62,5.97) -- (2.80,5.94) -- (2.97,5.92) -- (3.15,5.90) -- (3.32,5.89) -- (3.50,5.88) -- (3.67,5.88) -- (3.85,5.88) -- (4.02,5.89) -- (4.20,5.90) -- (4.38,5.91) -- (4.55,5.94) -- (4.72,5.97) -- (4.90,6.00) -- (5.07,6.04) -- (5.25,6.08) -- (5.42,6.13) -- (5.60,6.18) -- (5.77,6.24) -- (5.95,6.31) -- (6.12,6.37) -- (6.30,6.45);
\draw[cold, very thick] (0.00,2.59) -- (0.17,2.49) -- (0.35,2.40) -- (0.52,2.30) -- (0.70,2.20) -- (0.88,2.13) -- (1.05,2.07) -- (1.22,2.00) -- (1.40,1.93) -- (1.57,1.89) -- (1.75,1.84) -- (1.92,1.83) -- (2.10,1.82) -- (2.27,1.83) -- (2.45,1.84) -- (2.62,1.86) -- (2.80,1.87) -- (2.97,1.91) -- (3.15,1.96) -- (3.32,2.00) -- (3.50,2.04) -- (3.67,2.08) -- (3.85,2.12) -- (4.02,2.19) -- (4.20,2.26) -- (4.38,2.33) -- (4.55,2.40) -- (4.72,2.46) -- (4.90,2.53) -- (5.07,2.60) -- (5.25,2.67) -- (5.42,2.74) -- (5.60,2.81) -- (5.77,2.88) -- (5.95,2.95) -- (6.12,3.02) -- (6.30,3.08);
\draw[hot, dashed] (3.70,4.50) -- (3.70,5.88);
\draw[cold, dashed] (2.10,0.55) -- (2.10,1.82);
\filldraw[draw=black, fill=hot] (3.70,5.88) circle (3pt);
\filldraw[draw=black, fill=cold] (2.10,1.82) circle (3pt);
\filldraw[draw=black, fill=hot] (3.70,8.63) -- ++(-0.13,0.24) -- ++(0.26,0) -- cycle;
\node[anchor=south] at (3.70,8.90) {\footnotesize mean};
\filldraw[draw=black, fill=cold] (2.10,8.37) -- ++(-0.13,-0.24) -- ++(0.26,0) -- cycle;
\node[anchor=north] at (2.10,8.10) {\footnotesize median};
\node[anchor=west] at (7.2,5.65) {lowest at $c = \bar y = 5.29$, \ $\mathrm{MSE} = 33.13$};
\node[anchor=west] at (7.2,1.70) {lowest at $c = \mathrm{median} = 3$, \ $\mathrm{MAE} = 3.29$};
\pt{13.30,8.5}
\node[anchor=west] at (-0.6,-0.75) {The MSE minimum moved with the mean, from $4.29$ to $5.29$. The MAE minimum stayed at $3$.};
\end{scope}
\end{tikzpicture}
\end{document}

Properties

(Robust in , Weak in ) LAD regression resists outliers in the response and fails against points with extreme inputs.

A huge at an ordinary pulls the LAD fit with unit strength, like every other point. It therefore cannot move the line far. A point with an extreme input behaves differently. Its contribution to the subgradient with respect to is , so a large input carries a large weight. The fit then tilts toward that point until it passes close to it. LAD regression therefore has breakdown point for corrupted inputs, the same as least squares (Rousseeuw and Leroy, 1987). Methods with a high breakdown point, such as least median of squares or 4.4.1. RANSAC, handle bad inputs.

(Constant Pull Slows Convergence) Gradient descent on MAE does not slow down near the optimum.

Each point’s subgradient with respect to its prediction has size whatever the residual. The full subgradient therefore stays large near the minimum. A fixed learning rate then overshoots and oscillates around the optimum instead of settling. Subgradient methods converge with a decaying learning rate, such as . Deep learning frameworks set the gradient of at to , which picks one valid subgradient. These training issues are one reason Huber loss often replaces MAE as a training loss.

(Efficiency Cost) Under Gaussian noise the median needs about more data than the mean for the same precision.

The sample median of Gaussian values with variance has asymptotic variance , while the mean has variance . The ratio is the asymptotic efficiency of the median relative to the mean. Under Laplace noise with scale the comparison flips. The median has variance and the mean has , so the median is twice as efficient. MAE therefore gains on heavy-tailed noise and loses on Gaussian noise. Huber loss recovers most of the lost efficiency and keeps most of the robustness.

(Many Minimizers) The MAE minimizer can be a whole interval, and an optimal LAD fit passes through data points.

With an even number of values, every point between the two middle values is a median. For the values , every gives the same total absolute error of . LAD regression shows the same effect. Its objective is piecewise linear, so a minimum sits at a corner of the linear program. With predictors and an intercept, at least one optimal LAD fit passes exactly through data points. Software returns one of the optimal fits, and a small change in the data can make it jump to another.

(Quantile Loss) Tilting the absolute error gives a loss whose minimizer is any chosen quantile.

The pinball loss at level is

It charges per unit of underprediction () and per unit of overprediction (). Its minimizer is the -quantile of given . MAE is the case , since . Suppose a store loses dollars per unit of unmet demand and dollar per unsold unit. It should then stock the quantile of demand. Fitting a model with this loss is quantile regression (Koenker and Bassett, 1978). Prince (Understanding Deep Learning, ch. 5) lists it with the Laplace loss among regression losses.

Derivation

We show that a median minimizes the total absolute error. Let . Away from the data values, the term for has slope if and if . The slope of is therefore

The function is convex and piecewise linear. Its slope is negative while more than half of the values lie above . It is positive while more than half lie below. The minimum lies where the slope changes sign, which is at a median. A point far above adds to the slope, the same as a point barely above .

For the Laplace link, suppose with independent Laplace noise of scale . The Laplace density is a two-sided exponential density. The log-likelihood is

For fixed , maximizing minimizes the sum of absolute residuals. Setting gives , the training MAE. The Laplace tails decay like , much more slowly than the Gaussian . A model that expects large errors more often penalizes each one less.

Examples

(Easy) Late Deliveries

A delivery app predicts five delivery times in minutes. The true times are , and the predictions are .

(Medium) A Mansion on the Street

Five houses on one street sold for thousand dollars. An appraiser must quote one typical price for the street.

(Hard) Calibrating a Load Sensor

A load sensor should output volts per kilogram, with no offset. A technician applies loads kg and reads volts. The last reading is faulty.

See Also