Skip to content
ML to LLMs
Cheat sheets

Regression metrics

MAE, MSE, RMSE, R², and MAPE, with when to use each.

MetricFormulaUnitsUse whenWatch out
MAE1n∑∣y−y^∣\frac{1}{n}\sum\lvert y - \hat{y}\rverttarget unitsevery unit of error costs the same; outliers shouldn't dominatenot differentiable at 0 (fine for reporting)
MSE1n∑(y−y^)2\frac{1}{n}\sum(y - \hat{y})^2squared unitstraining loss; large errors are especially badhard to interpret
RMSEMSE\sqrt{\text{MSE}}target unitsreport MSE in readable unitsdominated by a few big misses
R²1−∑(y−y^)2∑(y−yˉ)21 - \frac{\sum(y-\hat{y})^2}{\sum(y-\bar{y})^2}nonecompare against predicting the meancan be negative on test data; not comparable across datasets
MAPE100%n∑∣y−y^y∣\frac{100\%}{n}\sum\left\lvert\frac{y - \hat{y}}{y}\right\rvertpercentrelative error across scalesexplodes near y=0y = 0; asymmetric
Huber lossquadratic near 0, linear beyond δrobust training losschoose δ

Worked example. Errors [−10,10,−10,10,−5][-10, 10, -10, 10, -5]: MAE 9.0, RMSE 9.2. Change one error to 100: MAE 28.0, RMSE 45.6. RMSE reacts five times more.

Always also: plot residuals versus predictions (curvature means a missing nonlinearity; a fan shape means non-constant variance), and compare against a baseline (mean, last value, seasonal naive).

Lessons: Linear regression · Regularization and regression metrics