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.
| MSE | 4.55 | squared units, outlier-sensitive |
| RMSE | 2.13 | same units as y |
| MAE | 1.74 | robust, same units |
| MedAE | 1.37 | very robust |
| R² | 0.886 | depends on target spread |
| MAPE | 6.4% | relative, asymmetric |
“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.
- 1. Which metric punishes one big miss the most?
- 2. R² compares the model with…
- 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))- 1. RMSE is always…
- 2. An R² of 0 means the model is…
- 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.
- 1. Which constant minimises MAE?
- 2. Test R² below 0 means…
- 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.
- 1. Two test sets, same RMSE, different R². Most likely cause?
- 2. RMSLE suits targets whose errors are…
- 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.
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
- R. J. Hyndman, A. B. Koehler (2006). “Another look at measures of forecast accuracy.” International Journal of Forecasting 22(4).
- T. O. Kvålseth (1985). “Cautionary note about R².” The American Statistician 39(4).
- S. Kim, H. Kim (2016). “A new metric of absolute percentage error for intermittent demand forecasts.” IJF 32(3).
- A. Saxena et al. (2008). “Damage propagation modeling for aircraft engine run-to-failure simulation.” PHM.
- T. Gneiting (2011). “Making and evaluating point forecasts.” JASA 106(494).