beginnermachine-learning

MAE vs MSE vs RMSE vs R²

Four ways to measure how wrong your model is — and why it matters which one you pick.

Key Points

What it is

These are regression error metrics — numbers that tell you how far off your model's predictions are from reality. MAE (Mean Absolute Error) is the average gap between predicted and actual values. MSE (Mean Squared Error) squares those gaps before averaging, punishing large errors more harshly. RMSE (Root Mean Squared Error) is MSE square-rooted back to the original unit. R² (R-squared) tells you what percentage of the variation in your data your model actually explains.

Why it exists

A model that predicts house prices can be wrong in many different ways — slightly wrong on most houses, or catastrophically wrong on a few. These metrics exist because different use cases care about different types of wrongness. A metric that treats all errors equally (MAE) is right for some problems. A metric that punishes large mistakes extra hard (MSE/RMSE) is right for others. Without these measures, you have no objective way to compare two models or know if your model is good enough.

What it measures

Each metric measures a different aspect of prediction error. MAE measures the typical size of your errors in plain units — dollars, degrees, kilograms. MSE measures the same but amplifies large errors so they dominate the score. RMSE brings MSE back to interpretable units. R² measures not the size of your errors but how much better your model is than simply predicting the mean every time — a score of 1.0 is perfect, 0.0 means your model adds no value over a naive guess.

Intuition

Imagine you are a weather forecaster. On Monday you are off by 2°, Tuesday by 3°, Wednesday by 10° (you missed a storm completely). MAE treats all three days equally — average error is 5°. MSE punishes Wednesday's disaster: 4 + 9 + 100 = 113, averaged to 37.7. RMSE brings that back to degrees: √37.7 = 6.1°. The big miss on Wednesday inflates your RMSE far above your MAE. That difference is the signal — RMSE tells you that you have an outlier problem, MAE hides it.

Formulas

MAE

MAE=1n∑i=1n∣yi−y^i∣\text{MAE} = \frac{1}{n}\sum_{i=1}^{n}|y_i - \hat{y}_i|
  • n — total number of predictions
  • yᵢ — the actual real value for row i
  • ŷᵢ — your model's predicted value for row i
  • |yᵢ − ŷᵢ| — absolute difference — negative errors count the same as positive
  • Σ / n — sum all differences then divide by count to get the average

MSE

MSE=1n∑i=1n(yi−y^i)2\text{MSE} = \frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y}_i)^2
  • n — total number of predictions
  • yᵢ — the actual real value for row i
  • ŷᵢ — your model's predicted value for row i
  • (yᵢ − ŷᵢ)² — squared difference — large errors become much larger
  • Σ / n — average squared error

RMSE

RMSE=1n∑i=1n(yi−y^i)2\text{RMSE} = \sqrt{\frac{1}{n}\sum_{i=1}^{n}(y_i - \hat{y}_i)^2}
  • n — total number of predictions
  • yᵢ — the actual real value for row i
  • ŷᵢ — your model's predicted value for row i
  • (yᵢ − ŷᵢ)² — squared difference (same as MSE)
  • √ — square root brings the units back to original — e.g. dollars, degrees

R²

R2=1−∑i=1n(yi−y^i)2∑i=1n(yi−yˉ)2R^2 = 1 - \frac{\sum_{i=1}^{n}(y_i - \hat{y}_i)^2}{\sum_{i=1}^{n}(y_i - \bar{y})^2}
  • yᵢ — actual real value for row i
  • ŷᵢ — predicted value for row i
  • ȳ — mean of the actual values (simple average)
  • numerator — sum of squared errors — what your model misses
  • denominator — total variance in the data — how wrong you would be if you always guessed the mean
  • 1 − ratio — proportion of variance your model explains

When to use

When not to use

Common mistakes

In practice

These metrics appear at the end of every regression model evaluation pipeline. In scikit-learn: mean_absolute_error(), mean_squared_error(), r2_score() from sklearn.metrics. In practice you compute all four, report MAE or RMSE to stakeholders, and use the MAE-RMSE gap to detect outlier sensitivity. When tuning models via cross-validation, the choice of which metric to optimise directly shapes what the model learns to minimise — choose carefully.

Was this concept helpful?

Spot an error or gap? Suggest an edit →

Related concepts

linear-regressionbias-variance-tradeoffclassification-metricsoverfitting-underfittingcross-validation
Chirp at me!