MAE MSE and RMSE
Quick answer
Regression error metrics summarize the distance between observed and predicted numbers. MAE averages absolute errors, MSE averages squared errors, and RMSE is the square root of MSE. Lower is better for all three. Static examples tested locally with Python 3.13.5, scikit-learn 1.8.0 SciPy 1.17.0 and NumPy 2.3.5 where imported. ByteMind package execution is unverified.
Calculate errors by hand
from math import sqrty=[2,4,8];p=[2,6,6]e=[a-b for a,b in zip(y,p)]mae=sum(map(abs,e))/len(e);mse=sum(x*x for x in e)/len(e)print(f"{mae:.3f} {mse:.3f} {sqrt(mse):.3f}")Observed local output:
1.333 2.667 1.633The two nonzero residuals cancel as signed errors, but not under absolute or squared loss.
How it works
For n paired observations define residual e = y - prediction. MAE = sum(abs(e))/n; MSE = sum(e²)/n; RMSE = sqrt(MSE). MAE and RMSE have target units (for example minutes); MSE has squared units. Squaring makes large errors influential: errors of 0 and 4 yield MAE 2, MSE 8 and RMSE about 2.828. The arithmetic mean minimizes total squared error for a constant prediction; a median minimizes total absolute error. Compare on identical held-out rows and target scales. For multiple outputs, specify whether each output is scored separately or averaged, and avoid averaging incompatible units without a justified normalization. Sample weights change the denominator to the sum of weights. A metric is an estimate on sampled data, not a population guarantee: for independent held-out rows, a paired bootstrap can quantify uncertainty in the difference between two models; resample entire entities or time blocks for dependent rows.
Compare large-error sensitivity
from sklearn.metrics import mean_absolute_error,mean_squared_error,root_mean_squared_errory=[0,0,0,0];a=[2,2,2,2];b=[0,0,0,8]for p in [a,b]: print(f"{mean_absolute_error(y,p):.1f} {mean_squared_error(y,p):.1f} {root_mean_squared_error(y,p):.1f}")Observed local output:
2.0 4.0 2.02.0 16.0 4.0Same MAE, different squared loss due to a concentrated error.
Common mistakes
Do not square the mean signed residual: cancellation hides error. RMSE is not mean absolute error. Avoid comparing MSE on dollars and cents without converting units.
Practice and next steps
Calculate errors for a constant median versus a constant mean on [1, 1, 10]. Explain which metric favors which predictor. Complete the knowledge check and staged exercise. Next: R squared and constant target.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
MAE MSE and RMSE — knowledge check
Apply mae mse and rmse to new scenarios.
Which metric has squared target units?
Which constant minimizes MAE?
Why can mean signed error be misleading?
Two models have equal MAE; can RMSE differ?
How should dependent samples be bootstrapped?