MAE, MSE and R-Squared Explained Simply
MAE, MSE and R-squared are common metrics used to evaluate regression models.
They help us understand how close a model's predictions are to the actual values.
Why Do Regression Metrics Matter?
Regression models predict numerical values such as prices, sales, scores or temperatures.
After making predictions, we need to measure how good those predictions are.
Example
If a model predicts house prices, we need to know whether its predictions are close to the real prices.
Regression metrics measure prediction error
Regression Example
Suppose a model predicts exam scores.
| Student |
Actual Score |
Predicted Score |
Error |
| A |
80 |
75 |
5 |
| B |
60 |
65 |
5 |
| C |
90 |
85 |
5 |
The model is not perfect, but the predictions are fairly close to the actual scores.
What is Prediction Error?
Prediction error is the difference between the actual value and the predicted value.
Error = Actual Value - Predicted Value
Example
Actual score = 80
Predicted score = 75
Error = 80 - 75 = 5
Simple idea: Smaller errors usually mean better predictions.
What is MAE?
MAE stands for Mean Absolute Error. It measures the average size of the prediction errors.
MAE = average of absolute errors
MAE ignores whether the error is positive or negative. It only looks at how far the prediction is from the actual value.
Simple meaning: On average, how far are the predictions from the real values?
MAE Example
| Actual |
Predicted |
Absolute Error |
| 80 |
75 |
5 |
| 60 |
65 |
5 |
| 90 |
85 |
5 |
MAE = (5 + 5 + 5) ÷ 3 = 5
This means the model is wrong by about 5 marks on average.
What is MSE?
MSE stands for Mean Squared Error. It squares each error before calculating the average.
MSE = average of squared errors
Because errors are squared, larger errors are punished more heavily.
Simple meaning: MSE gives more penalty to large mistakes.
MSE Example
| Actual |
Predicted |
Error |
Squared Error |
| 80 |
75 |
5 |
25 |
| 60 |
65 |
-5 |
25 |
| 90 |
85 |
5 |
25 |
MSE = (25 + 25 + 25) ÷ 3 = 25
MAE vs MSE
| Metric |
Meaning |
Key Feature |
| MAE |
Average absolute error |
Easy to understand |
| MSE |
Average squared error |
Punishes large errors more |
Business Interpretation
If large prediction mistakes are very costly, MSE can be useful because it highlights those bigger errors more strongly.
What is RMSE?
RMSE stands for Root Mean Squared Error. It is the square root of MSE.
RMSE = square root of MSE
RMSE is useful because it brings the error back to the same unit as the target variable.
Example: If predicting house prices in pounds, RMSE is also interpreted in pounds.
What is R-Squared?
R-squared, also written as R², measures how well the model explains the variation in the target variable.
R² = how much of the variation is explained by the model
R² is often shown as a value between 0 and 1.
| R² Value |
Simple Meaning |
| 0 |
Model explains none of the variation |
| 0.5 |
Model explains about half of the variation |
| 1 |
Model explains all of the variation perfectly |
R-Squared Example
Example
If R² = 0.80, the model explains about 80% of the variation in the target variable.
This usually means the model has captured a strong relationship in the data.
Important: A high R² does not always mean the model is good. Always check errors and business context too.
Which Metric Should You Use?
| Metric |
Use When |
| MAE |
You want an easy-to-understand average error |
| MSE |
You want to penalise large errors more heavily |
| RMSE |
You want an error metric in the original unit |
| R² |
You want to know how well the model explains variation |
Metrics in Python
Scikit-learn provides simple functions for regression metrics.
from sklearn.metrics import mean_absolute_error, mean_squared_error, r2_score
import numpy as np
mae = mean_absolute_error(y_test, predictions)
mse = mean_squared_error(y_test, predictions)
rmse = np.sqrt(mse)
r2 = r2_score(y_test, predictions)
print("MAE:", mae)
print("MSE:", mse)
print("RMSE:", rmse)
print("R²:", r2)
Business Example
A company builds a model to predict monthly sales.
Example Results
MAE = £500
RMSE = £750
R² = 0.82
This means the model is wrong by about £500 on average, larger errors are around £750, and the model explains
a strong amount of variation in sales.
Common Beginner Mistakes
- Looking only at R² and ignoring prediction error
- Assuming lower MSE is always meaningful without context
- Comparing errors from datasets with different units
- Forgetting that MAE and RMSE are easier to interpret than MSE
- Ignoring business impact of prediction errors
Remember: Evaluation metrics should be interpreted in the context of the business problem.
Quick Practice
A sales prediction model has the following result:
Question: What does this mean?
Suggested answer: The model's predictions are wrong by about £200 on average.
Key Takeaway
MAE, MSE, RMSE and R-squared help evaluate regression models.
MAE is easy to understand, MSE penalises large errors, RMSE gives error in the original unit, and R² explains how well the model captures variation.
Simple rule: Use error metrics to understand how far predictions are from reality.
Want to Learn More?
Explore our practical courses in Data Analysis, Machine Learning and AI to apply regression evaluation metrics in real-world projects.
View Courses