Home / Machine Learning

Evaluation Metrics for Regression

By Updated

Interact with the line and data points to see how MAE, MSE, RMSE, and $R^2$ quantify model performance in real-time.

2.5
30
Interactive Plot
Regression Line
$y_{pred} =$ 1.20$x$ + 2.00

Mean Absolute Error

MAE
0.000
Average of absolute differences. Treats all errors equally.

Mean Squared Error

MSE
0.000
Average of squared differences. Heavily punishes large errors (outliers).

Root Mean Sq. Error

RMSE
0.000
Square root of MSE. Returns error metric to original units.

R-Squared Score

$R^2$ (Coeff. of Det.)
0.000
Proportion of variance explained by the model. 1.0 is perfect, <0 is worse than mean.

Overview

Regression metrics summarize how far numeric predictions are from observed values, but they weight errors differently. For residual eᵢ = yᵢ − ŷᵢ, MAE averages absolute errors while MSE squares them, so large misses count more.

Four common metrics

For n observations, let eᵢ = yᵢ − ŷᵢ.

  • Mean absolute error (MAE) = average of |eᵢ|. It is in the target’s units and treats each unit of error linearly.
  • Mean squared error (MSE) = average of eᵢ². It penalizes large errors more strongly and has squared target units.
  • Root mean squared error (RMSE) = square root of MSE. It restores the target’s units while retaining the stronger penalty on large errors.
  • R-squared = R² = 1 − SSE/SST, where SSE is squared prediction error and SST is variation around the target mean. It compares the model with predicting the mean; on test data it can be negative if the model performs worse than that baseline.

Worked example: one large miss

Suppose three predictions have absolute errors 1, 1, and 4 units. MAE is (1 + 1 + 4)/3 = 2. MSE is (1² + 1² + 4²)/3 = 6, so RMSE is about 2.45. The 4-unit miss contributes 16 to the squared-error total, which explains why MSE and RMSE react more to large errors than MAE.

Use MAE when errors should count linearly and the result should be easy to explain. Use RMSE when large misses deserve extra weight. MSE is common as an optimization loss but its squared units are less intuitive. R-squared describes improvement over the mean baseline, not the typical error size; report it alongside MAE or RMSE when useful.

A nearby metric: percentage error

Mean absolute percentage error (MAPE) divides absolute error by the actual value. It can be useful when relative error is meaningful, but it is undefined at zero and unstable near zero. It can also weight over- and under-prediction asymmetrically. Do not use it blindly for demand or other targets that can be zero.

Common mistakes with Evaluation Metrics for Regression

  • Calling RMSE universally best: the metric should match the costs of errors.
  • Comparing R-squared across unrelated datasets: its value depends on target variance and data composition.
  • Ignoring target units: MAE and RMSE are interpretable only with the target’s scale in mind.
  • Choosing a metric after seeing test results: select the evaluation rule before final testing.

Sources and next steps

Predict, then reveal

About to run: set Data Points to its maximum (100). Before it does — what happens to the readout?

Committing to an answer first is the point — the reveal runs the experiment on the visualisation above and reads the real value back, so nothing here is scripted.

Recall check

0 of 3

Say the answer out loud before you reveal it — recalling it is what makes it stick, and rereading it is not.

  1. What does this module say about “Start with residuals”?

  2. What does this module say about “Worked example: one large miss”?

  3. What does this module say about “A nearby metric: percentage error”?

Cheat sheet

Evaluation Metrics for Regression

Compare MAE, MSE, RMSE and R-squared on identical predictions and see which kinds of error each metric punishes hardest.

MACHINE LEARNING · vizlearn.in/machine_learning/evaluation_metrics_for_regression.html

About the author

Ashish Jangra builds and maintains VizLearn. Every module here is written and the visualisation behind it hand-built, so the numbers in a readout come from the same code that draws the picture. Corrections are genuinely welcome and get priority over everything else — if a page states something wrong, or an animation misrepresents what the algorithm does, get in touch.