Foundations to Frontier
Tests
D. Classical Machine Learning › D0 Core Concepts (concept pages)

Regression Metrics: MSE, RMSE, MAE, R², Adjusted R² and MAPE

A regression model is judged by how far its predictions are from the truth, but 'how far' can be measured in many ways. MSE and RMSE weight large errors heavily, MAE and the median absolute error are robust, R² compares the model with always predicting the mean, adjusted R² penalises extra features, and MAPE measures relative error. Each answers a different question and each can mislead. This page defines the metrics, their units, the statistic each rewards, and their pitfalls. In the exercises you implement the metrics and their relations; then you measure how training R² rises with useless features, how R² for the same model swings with the spread of the targets, and how MAPE rewards under-prediction.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

How wrong, on average?

If you guess the weight of ten parcels, you can score yourself in different ways:

  • add up how many kilograms you were off (MAE);
  • punish big misses much more by squaring them (MSE, or its square root RMSE);
  • measure how wrong you were in percent (MAPE);
  • compare yourself with a lazy guesser who always says the average weight (R²).

The same guesses can look good on one scoreboard and bad on another.

One model, six regression metrics
actualpredicted
MSE4.55squared units, outlier-sensitive
RMSE2.13same units as y
MAE1.74robust, same units
MedAE1.37very robust
R²0.886depends on target spread
MAPE6.4%relative, asymmetric
Try: keep the noise fixed and shrink the spread of the targets: RMSE stays the same but R² collapses, because R² compares the errors with the variance of y. Switch on the outlier: MSE and RMSE jump, MAE moves a little, MedAE barely changes.
Why engineers care

“Our thrust model has R² = 0.98” sounds great until you learn the error is 400 N on a 500 N margin. Reporting the right metric, in physical units, is what lets engineers decide whether a model is safe to use.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Which metric punishes one big miss the most?
  2. 2. R² compares the model with…
  3. 3. MAPE measures error in…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

The metrics

Metric Formula Units Best for
MSE mean (y − ŷ)² y² optimisation, Gaussian noise
RMSE √MSE y reporting typical error with large errors weighted
MAE mean |y − ŷ| y robust typical error
MedAE median |y − ŷ| y very robust
R² 1 − SS_res / SS_tot none fraction of variance explained
adjusted R² 1 − (1 − R²)(n − 1)/(n − p − 1) none comparing linear models with different p
MAPE mean |y − ŷ| / |y| % relative error when y is far from 0

Related: sMAPE (symmetric version), RMSLE (errors of log(1 + y), for multiplicative errors), max error (worst case), and the pinball loss for quantiles (D0.6).

from sklearn.metrics import mean_squared_error, root_mean_squared_error, mean_absolute_error, r2_score, mean_absolute_percentage_error
print(root_mean_squared_error(y, p), mean_absolute_error(y, p), r2_score(y, p), mean_absolute_percentage_error(y, p))
📝 Quick check (Level 1)
0/3 answered
  1. 1. RMSE is always…
  2. 2. An R² of 0 means the model is…
  3. 3. MAPE is a bad choice when…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 35 minUndergraduate students and practising engineers.

What each metric rewards

  • MSE is minimised by the conditional mean. It decomposes as MSE = (mean error)² + variance of errors, so it shows both bias and scatter.
  • MAE is minimised by the median.
  • MAPE weights each error by 1/y. Over-predicting a small value costs more than under-predicting a large one, so MAPE favours under-prediction. The MAPE-optimal constant is the “weighted median” with weights 1/y, below the ordinary median.
  • R² = 1 − MSE / Var(y). For a fixed model quality (fixed MSE), R² rises or falls with the variance of the test targets. It can be negative on test data.
  • Adjusted R² removes the automatic rise of R² with each added feature in linear models. It estimates population R², not out-of-sample performance of the fitted model.
🐍 Exercise 1: regression metrics from scratch
Implement MSE, RMSE, MAE, median and max absolute error, R², adjusted R², MAPE, sMAPE and RMSLE; check them on a small example; verify R² is 0 for the mean predictor, 1 for a perfect one and negative for a bad one, and that RMSE ≥ MAE.
📝 Quick check (Level 2)
0/3 answered
  1. 1. Which constant minimises MAE?
  2. 2. Test R² below 0 means…
  3. 3. MSE = bias² + …

Level 3: Advanced

★★★★☆ Advanced⏱ 30 minGraduate level, with full derivations and proofs.

Reporting regression results

  • Report errors in physical units (RMSE and MAE) next to any unitless score, and the range or standard deviation of y for context.
  • Compare with baselines: predicting the mean, last value, or a physics model. R² is itself a comparison with the mean baseline.
  • Look at residuals: plots against predictions and features, by segment, and the worst cases. One number hides heteroscedasticity and bias in subgroups.
  • Uncertainty: bootstrap confidence intervals of the metric over test examples.
  • Choose the training loss to match the reporting metric where possible (D0.6).

Interview questions.

  • Why might R² improve when you test on a wider range of conditions even though the model is the same? Var(y) grows while MSE stays similar.
  • Why is MAPE problematic for demand forecasting with zero sales? It is undefined at zero, explodes near zero, and is biased toward under-forecasts.
📝 Quick check (Level 3)
0/3 answered
  1. 1. Two test sets, same RMSE, different R². Most likely cause?
  2. 2. RMSLE suits targets whose errors are…
  3. 3. Best way to show a metric's uncertainty?

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

Metrics that mislead, measured

Exercise 1. For y = (3, 5, 2, 7) and ŷ = (2.5, 5, 3, 8):

Metric Value
MSE 0.5625
RMSE 0.75
MAE 0.625
R² 0.847
adjusted R² (p = 1) 0.771
MAPE 20.2%

Exercise 2a: useless features (n = 60, 3 real features plus k noise features, OLS, 50 datasets).

k train R² adjusted R² test R²
0 0.696 0.679 0.677
10 0.751 0.681 0.603
20 0.802 0.676 0.484
30 0.865 0.693 0.254
40 0.912 0.676 −0.155

Training R² climbs steadily as noise features are added. Adjusted R² correctly stays flat at the population value (about 0.68). But only held-out R² reveals that the fitted model gets worse and finally loses to the mean. Adjusted R² estimates how much variance the features could explain, not how well this estimated model predicts.

Exercise 2b: the same model on different test ranges (ŷ = 2x, noise σ = 1).

x range RMSE R²
0–10 1.00 0.971
0–3 0.99 0.745
4–5 1.00 0.255

Identical error, wildly different R².

Exercise 2c: MAPE on log-normal targets (median 20.0, mean 24.1). The single best constant is:

  • 24.06 for MSE (the mean);
  • 20.01 for MAE (the median);
  • 14.0 for MAPE.

At that MAPE-optimal value, only 27.5% of targets lie below the prediction. A model tuned for MAPE systematically under-predicts.

🐍 Exercise 2 (research): how regression metrics mislead
Add 0–40 pure-noise features to an OLS model and compare training, adjusted and test R²; evaluate one fixed model on test sets with narrow and wide target ranges; find the constant prediction that minimises MSE, MAE and MAPE for log-normal targets.

Regression metrics in AI, robotics and aerospace

  • State estimation and navigation: RMSE of position in metres, plus maximum error for safety cases.
  • Remaining-useful-life prediction: asymmetric scores that penalise late predictions more than early ones (NASA C-MAPSS scoring).
  • Energy and load forecasting: MAPE and sMAPE are common, but RMSE or pinball loss is preferred where values near zero occur.
  • Surrogate models of simulations: R² across the design space, plus maximum error over critical regions.

References

  1. R. J. Hyndman, A. B. Koehler (2006). “Another look at measures of forecast accuracy.” International Journal of Forecasting 22(4).
  2. T. O. Kvålseth (1985). “Cautionary note about R².” The American Statistician 39(4).
  3. S. Kim, H. Kim (2016). “A new metric of absolute percentage error for intermittent demand forecasts.” IJF 32(3).
  4. A. Saxena et al. (2008). “Damage propagation modeling for aircraft engine run-to-failure simulation.” PHM.
  5. T. Gneiting (2011). “Making and evaluating point forecasts.” JASA 106(494).