Regression Metrics

Regression metrics score numeric predictions against true values . Most of them average a pointwise loss that depends only on the residual :

Here is the number of predictions, and is the empirical risk on those points. The same average serves as a training loss on the training set and as an evaluation metric on held-out data. The family has four members:

  • Mean squared error (MSE) averages . Its square root, the RMSE, is in the units of .
  • Mean absolute error (MAE) averages .
  • Huber loss is quadratic for and linear beyond the threshold .
  • R-squared () is , the share of the variance of that the model explains. It is a ratio of two sums of squares, so it has no pointwise form.

The decision rule is as follows:

  • MSE or RMSE is the default metric to report and the default loss to train with.
  • MAE fits when a few large errors dominate or when the median is the quantity of interest.
  • Huber loss is the training loss when both matter, smooth gradients near zero and robustness to a few large errors.
  • compares the quality of fit across targets measured on different scales.

Some data contain a large fraction of gross mismatches, such as wrong feature matches in vision. A robust loss is not enough there, and 4.4.1. RANSAC fits the model to a consensus subset and ignores the other points.

Intuition

All four metrics start from the residuals. They differ in how fast the penalty grows with the size of a residual. Squared error grows quadratically, so a residual of costs times as much as a residual of . Absolute error grows linearly, so the same residual costs times as much. A squared-error fit therefore moves toward its largest errors. An absolute-error fit gives each point a pull of fixed size. Huber loss is quadratic for small residuals and linear for large ones.

Each loss has its own best constant prediction, the mean under squared error and the median under absolute error. A faster-growing loss also lets one outlier move the fit further. The losses differ in efficiency and robustness. An efficient estimator has low variance for a given amount of data. The mean is the most efficient choice under Gaussian noise. A robust estimator stays near the truth when a few points are corrupted, and the median is the standard example. differs from the other three in another way. It divides the squared error by the variance of , so it has no units. It can therefore compare a model of prices with a model of delivery times.

The animation moves one point upward and refits three lines at each step. The least-squares line follows the point. The LAD line stays put, and the Huber line stops once the point’s residual passes .

\usepackage{tikz}
\usetikzlibrary{animations, arrows.meta}
\begin{document}
\definecolor{hot}{HTML}{D9483B}
\definecolor{cold}{HTML}{2F80ED}
\definecolor{grn}{HTML}{2F9E44}
\newcommand{\pt}[1]{\fill (#1) circle (2.4pt);}
\begin{tikzpicture}[font=\small, >={Stealth[length=2.2mm]}]
\draw[->] (-0.31,0) -- (7.69,0) node[right] {$x$};
\draw[->] (-0.31,0) -- (-0.31,6.64) node[above] {$y$};
\draw (0.00,-0.08) -- (0.00,0.08) node[pos=0, below] {\footnotesize $0$};
\draw (2.34,-0.08) -- (2.34,0.08) node[pos=0, below] {\footnotesize $3$};
\draw (4.68,-0.08) -- (4.68,0.08) node[pos=0, below] {\footnotesize $6$};
\draw (7.02,-0.08) -- (7.02,0.08) node[pos=0, below] {\footnotesize $9$};
\draw (-0.39,2.00) -- (-0.23,2.00) node[pos=0, left] {\footnotesize $5$};
\draw (-0.39,4.00) -- (-0.23,4.00) node[pos=0, left] {\footnotesize $10$};
\draw (-0.39,6.00) -- (-0.23,6.00) node[pos=0, left] {\footnotesize $15$};
\draw[->] (10.2,0.3) -- (14.70,0.3) node[right] {\footnotesize shift};
\draw[->] (10.2,0.3) -- (10.2,4.50);
\node[anchor=south] at (10.60,4.50) {slope $\beta_1$};
\draw (10.12,0.86) -- (10.28,0.86) node[pos=0, left] {\footnotesize $0.6$};
\draw (10.12,1.97) -- (10.28,1.97) node[pos=0, left] {\footnotesize $0.8$};
\draw (10.12,3.09) -- (10.28,3.09) node[pos=0, left] {\footnotesize $1.0$};
\draw (10.12,4.20) -- (10.28,4.20) node[pos=0, left] {\footnotesize $1.2$};
\draw (10.20,0.22) -- (10.20,0.38) node[pos=0, below] {\footnotesize $0$};
\draw (11.60,0.22) -- (11.60,0.38) node[pos=0, below] {\footnotesize $3$};
\draw (13.00,0.22) -- (13.00,0.38) node[pos=0, below] {\footnotesize $6$};
\draw (14.40,0.22) -- (14.40,0.38) node[pos=0, below] {\footnotesize $9$};
\draw[hot, very thick] (8.8,7.05) -- (9.35,7.05) node[right, text=black] {\footnotesize least squares (MSE)};
\draw[cold, very thick] (8.8,6.45) -- (9.35,6.45) node[right, text=black] {\footnotesize least absolute dev.\ (MAE)};
\draw[grn, very thick] (8.8,5.85) -- (9.35,5.85) node[right, text=black] {\footnotesize Huber, $\delta = 1$};
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.8s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (10.20,0.72) -- (10.55,0.95);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.8s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (10.20,0.94) -- (10.55,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.8s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (10.20,0.72) -- (10.55,0.95);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.1s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (10.55,0.95) -- (10.90,1.17);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.1s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (10.55,0.94) -- (10.90,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.1s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (10.55,0.95) -- (10.90,1.06);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.7s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (10.90,1.17) -- (11.25,1.40);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.7s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (10.90,0.94) -- (11.25,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.7s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (10.90,1.06) -- (11.25,1.06);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (11.25,1.40) -- (11.60,1.63);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (11.25,0.94) -- (11.60,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (11.25,1.06) -- (11.60,1.06);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.3s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (11.60,1.63) -- (11.95,1.86);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.3s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (11.60,0.94) -- (11.95,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.3s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (11.60,1.06) -- (11.95,1.06);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.6s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (11.95,1.86) -- (12.30,2.09);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.6s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (11.95,0.94) -- (12.30,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.6s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (11.95,1.06) -- (12.30,1.06);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.9s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (12.30,2.09) -- (12.65,2.31);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.9s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (12.30,0.94) -- (12.65,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.9s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (12.30,1.06) -- (12.65,1.06);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.2s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (12.65,2.31) -- (13.00,2.54);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.2s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (12.65,0.94) -- (13.00,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.2s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (12.65,1.06) -- (13.00,1.06);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.5s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (13.00,2.54) -- (13.35,2.77);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.5s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (13.00,0.94) -- (13.35,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.5s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (13.00,1.06) -- (13.35,1.06);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.8s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (13.35,2.77) -- (13.70,3.00);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.8s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (13.35,0.94) -- (13.70,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.8s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (13.35,1.06) -- (13.70,1.06);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.1s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (13.70,3.00) -- (14.05,3.23);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.1s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (13.70,0.94) -- (14.05,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.1s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (13.70,1.06) -- (14.05,1.06);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.4s = "true", 11.8s = "true", repeats}}}]
\draw[hot, thick] (14.05,3.23) -- (14.40,3.45);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.4s = "true", 11.8s = "true", repeats}}}]
\draw[cold, thick] (14.05,0.94) -- (14.40,0.94);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.4s = "true", 11.8s = "true", repeats}}}]
\draw[grn, thick] (14.05,1.06) -- (14.40,1.06);
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "true", 2.8s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.73) -- (7.49,3.03);
\draw[grn, line width=1.3pt] (-0.31,0.73) -- (7.49,3.03);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\pt{7.02,2.99}\draw[thick] (7.02,2.99) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 0.58$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.58$};
\draw[dashed] (10.20,0.3) -- (10.20,4.20);
\filldraw[draw=black, fill=hot] (10.20,0.72) circle (2.4pt);
\filldraw[draw=black, fill=grn] (10.20,0.72) circle (2.4pt);
\filldraw[draw=black, fill=cold] (10.20,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {Ten points lie near a line. All residuals are below $\delta = 1$, so Huber equals least squares.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 2.8s = "true", 3.1s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.67) -- (7.49,3.14);
\draw[grn, line width=1.3pt] (-0.31,0.67) -- (7.49,3.14);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,3.29);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,3.29}\draw[thick] (7.02,3.29) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 0.62$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.62$};
\draw[dashed] (10.55,0.3) -- (10.55,4.20);
\filldraw[draw=black, fill=hot] (10.55,0.95) circle (2.4pt);
\filldraw[draw=black, fill=grn] (10.55,0.95) circle (2.4pt);
\filldraw[draw=black, fill=cold] (10.55,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {One point moves up. All three lines are refit at every step.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 3.1s = "true", 5.7s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.62) -- (7.49,3.25);
\draw[grn, line width=1.3pt] (-0.31,0.65) -- (7.49,3.19);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,3.59);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,3.59}\draw[thick] (7.02,3.59) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 0.66$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.64$};
\draw[dashed] (10.90,0.3) -- (10.90,4.20);
\filldraw[draw=black, fill=hot] (10.90,1.17) circle (2.4pt);
\filldraw[draw=black, fill=grn] (10.90,1.06) circle (2.4pt);
\filldraw[draw=black, fill=cold] (10.90,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {The point's Huber residual now exceeds $\delta = 1$, so its pull is capped. Huber stops moving.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 5.7s = "true", 6s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.57) -- (7.49,3.37);
\draw[grn, line width=1.3pt] (-0.31,0.65) -- (7.49,3.19);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,3.89);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,3.89}\draw[thick] (7.02,3.89) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 0.70$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.64$};
\draw[dashed] (11.25,0.3) -- (11.25,4.20);
\filldraw[draw=black, fill=hot] (11.25,1.40) circle (2.4pt);
\filldraw[draw=black, fill=grn] (11.25,1.06) circle (2.4pt);
\filldraw[draw=black, fill=cold] (11.25,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {One point moves up. All three lines are refit at every step.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6s = "true", 6.3s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.52) -- (7.49,3.48);
\draw[grn, line width=1.3pt] (-0.31,0.65) -- (7.49,3.19);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,4.19);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,4.19}\draw[thick] (7.02,4.19) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 0.74$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.64$};
\draw[dashed] (11.60,0.3) -- (11.60,4.20);
\filldraw[draw=black, fill=hot] (11.60,1.63) circle (2.4pt);
\filldraw[draw=black, fill=grn] (11.60,1.06) circle (2.4pt);
\filldraw[draw=black, fill=cold] (11.60,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {One point moves up. All three lines are refit at every step.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.3s = "true", 6.6s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.47) -- (7.49,3.59);
\draw[grn, line width=1.3pt] (-0.31,0.65) -- (7.49,3.19);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,4.49);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,4.49}\draw[thick] (7.02,4.49) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 0.78$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.64$};
\draw[dashed] (11.95,0.3) -- (11.95,4.20);
\filldraw[draw=black, fill=hot] (11.95,1.86) circle (2.4pt);
\filldraw[draw=black, fill=grn] (11.95,1.06) circle (2.4pt);
\filldraw[draw=black, fill=cold] (11.95,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {One point moves up. All three lines are refit at every step.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.6s = "true", 6.9s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.42) -- (7.49,3.71);
\draw[grn, line width=1.3pt] (-0.31,0.65) -- (7.49,3.19);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,4.79);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,4.79}\draw[thick] (7.02,4.79) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 0.82$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.64$};
\draw[dashed] (12.30,0.3) -- (12.30,4.20);
\filldraw[draw=black, fill=hot] (12.30,2.09) circle (2.4pt);
\filldraw[draw=black, fill=grn] (12.30,1.06) circle (2.4pt);
\filldraw[draw=black, fill=cold] (12.30,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {One point moves up. All three lines are refit at every step.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 6.9s = "true", 7.2s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.37) -- (7.49,3.82);
\draw[grn, line width=1.3pt] (-0.31,0.65) -- (7.49,3.19);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,5.09);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,5.09}\draw[thick] (7.02,5.09) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 0.86$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.64$};
\draw[dashed] (12.65,0.3) -- (12.65,4.20);
\filldraw[draw=black, fill=hot] (12.65,2.31) circle (2.4pt);
\filldraw[draw=black, fill=grn] (12.65,1.06) circle (2.4pt);
\filldraw[draw=black, fill=cold] (12.65,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {One point moves up. All three lines are refit at every step.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.2s = "true", 7.5s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.32) -- (7.49,3.93);
\draw[grn, line width=1.3pt] (-0.31,0.65) -- (7.49,3.19);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,5.39);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,5.39}\draw[thick] (7.02,5.39) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 0.90$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.64$};
\draw[dashed] (13.00,0.3) -- (13.00,4.20);
\filldraw[draw=black, fill=hot] (13.00,2.54) circle (2.4pt);
\filldraw[draw=black, fill=grn] (13.00,1.06) circle (2.4pt);
\filldraw[draw=black, fill=cold] (13.00,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {One point moves up. All three lines are refit at every step.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.5s = "true", 7.8s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.27) -- (7.49,4.05);
\draw[grn, line width=1.3pt] (-0.31,0.65) -- (7.49,3.19);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,5.69);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,5.69}\draw[thick] (7.02,5.69) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 0.94$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.64$};
\draw[dashed] (13.35,0.3) -- (13.35,4.20);
\filldraw[draw=black, fill=hot] (13.35,2.77) circle (2.4pt);
\filldraw[draw=black, fill=grn] (13.35,1.06) circle (2.4pt);
\filldraw[draw=black, fill=cold] (13.35,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {One point moves up. All three lines are refit at every step.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 7.8s = "true", 8.1s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.22) -- (7.49,4.16);
\draw[grn, line width=1.3pt] (-0.31,0.65) -- (7.49,3.19);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,5.99);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,5.99}\draw[thick] (7.02,5.99) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 0.98$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.64$};
\draw[dashed] (13.70,0.3) -- (13.70,4.20);
\filldraw[draw=black, fill=hot] (13.70,3.00) circle (2.4pt);
\filldraw[draw=black, fill=grn] (13.70,1.06) circle (2.4pt);
\filldraw[draw=black, fill=cold] (13.70,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {One point moves up. All three lines are refit at every step.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.1s = "true", 8.4s = "false", 11.8s = "false", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.17) -- (7.49,4.27);
\draw[grn, line width=1.3pt] (-0.31,0.65) -- (7.49,3.19);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,6.29);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,6.29}\draw[thick] (7.02,6.29) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 1.03$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.64$};
\draw[dashed] (14.05,0.3) -- (14.05,4.20);
\filldraw[draw=black, fill=hot] (14.05,3.23) circle (2.4pt);
\filldraw[draw=black, fill=grn] (14.05,1.06) circle (2.4pt);
\filldraw[draw=black, fill=cold] (14.05,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {One point moves up. All three lines are refit at every step.};
\end{scope}
\begin{scope}[animate = {myself: = {:visible = {0s = "false", 8.4s = "true", 11.8s = "true", repeats}}}]
\draw[hot, line width=2.4pt] (-0.31,0.12) -- (7.49,4.39);
\draw[grn, line width=1.3pt] (-0.31,0.65) -- (7.49,3.19);
\draw[cold, line width=1.3pt] (-0.31,0.67) -- (7.49,3.13);
\pt{0.00,0.71}
\pt{0.78,1.02}
\pt{1.56,1.51}
\pt{2.34,1.61}
\pt{3.12,1.53}
\pt{3.90,2.00}
\pt{4.68,2.15}
\pt{5.46,2.50}
\pt{6.24,2.49}
\draw[dashed] (7.02,2.99) -- (7.02,6.59);
\draw (7.02,2.99) circle (2.4pt);
\pt{7.02,6.59}\draw[thick] (7.02,6.59) circle (5pt);
\node[anchor=east] at (15.0,7.05) {$\beta_1 = 1.07$};
\node[anchor=east] at (15.0,6.45) {$\beta_1 = 0.61$};
\node[anchor=east] at (15.0,5.85) {$\beta_1 = 0.64$};
\draw[dashed] (14.40,0.3) -- (14.40,4.20);
\filldraw[draw=black, fill=hot] (14.40,3.45) circle (2.4pt);
\filldraw[draw=black, fill=grn] (14.40,1.06) circle (2.4pt);
\filldraw[draw=black, fill=cold] (14.40,0.94) circle (2.4pt);
\node[anchor=west] at (-0.6,-1.15) {Least squares follows the point. LAD never moved. Huber moved a little, then stopped.};
\end{scope}
\end{tikzpicture}
\end{document}

Comparison Table

MetricFormulaUnitsMinimizerOutlier sensitivityDifferentiable at 0Probabilistic viewDefault use
MSE (and RMSE) (RMSE ) (RMSE: )meanhigh, a residual’s pull grows with its sizeyesGaussian noisedefault metric and training loss
MAEmedianlow, every pull has size no, subgradient Laplace noisetypical error with outliers, median forecasts
Huber for , else median as , mean for large low, pulls capped at yes, the second derivative jumps at Gaussian center, Laplace tailstraining with occasional outliers, box regression
$R^2$nonesame fit as MSEhigh, as MSEyes, as SSEnone, a descriptive ratiocomparing fit across targets, OLS summaries

When to Use Which

Start with MSE as the training loss and RMSE as the reported number. RMSE is in the units of , so a reader can compare it with typical values of the target. Least squares and most regression software minimize squared error, and its gradient is smooth everywhere. Report MAE instead when a few large errors would dominate RMSE, or when readers care about the typical error. Train with MAE when the median is the right point forecast. A forecaster wants the median when each unit of error costs the same in both directions. Train with Huber loss when the noise is mostly Gaussian with occasional outliers. It keeps the efficiency of squared error near zero and caps the pull of large residuals. A common threshold is , with a robust estimate of the noise scale. Report next to RMSE when readers need a unitless number or must compare targets on different scales. Compute it on held-out data for model comparison, where it can be negative. MAE and Huber loss only cap the pull of large residuals. A point with an extreme input can still move the fit far. Both losses fail when outliers make up a large share of the data. Use 4.4.1. RANSAC in those cases.

Examples

(Easy) One Late Delivery, Four Scores

A delivery app predicts six delivery times in minutes. The true times are , and the predictions are . The last delivery hit a road closure.

See Also