We've seen how Mean Squared Error (MSE) quantifies the average squared difference between actual (y) and predicted (y^) values. While MSE effectively penalizes larger errors, its units are squared (e.g., dollars squared), which can sometimes make interpretation less intuitive.
To bring the error metric back into the original units of your target variable, we calculate the Root Mean Squared Error (RMSE). It's simply the square root of the Mean Squared Error.
Calculation
The formula for RMSE follows directly from MSE:
RMSE=MSE=n1i=1∑n(yi−y^i)2
Let's break this down:
As before, yi is the actual value and y^i is the predicted value for the i-th observation.
(yi−y^i) is the prediction error.
We square each error: (yi−y^i)2.
We sum these squared errors: ∑i=1n(yi−y^i)2.
We find the average of the squared errors (this is the MSE): n1∑i=1n(yi−y^i)2.
Finally, we take the square root of the MSE to get the RMSE.
Interpretation
The main benefit of RMSE is its interpretability. Because we take the square root, the RMSE is expressed in the same units as the original target variable (y).
If you are predicting house prices in dollars, the RMSE is also in dollars. An RMSE of 15,000suggeststhatthetypicaldeviationofthemodel′spricepredictionsfromtheactualpricesisaround15,000.
If you are predicting temperature in degrees Celsius, the RMSE is in degrees Celsius.
Like MSE, RMSE gives disproportionately high weight to large errors because the errors are squared before being averaged. A model that produces even a few predictions with very large errors will have a significantly higher RMSE than a model with similar average error magnitude but fewer extreme errors.
Lower values of RMSE indicate a better fit of the model to the data. An RMSE of 0 means the model made perfect predictions for every observation in the dataset.
Example Calculation
Let's use a small dataset of actual temperatures and predicted temperatures (in degrees Celsius):
Actual (yi)
Predicted (y^i)
Error (yi−y^i)
Squared Error ((yi−y^i)2)
22
23
-1
1
25
24
1
1
19
21
-2
4
28
26
2
4
Total
10
Calculate Errors: Find the difference between each actual and predicted value.
Calculate Squared Errors: Square each error.
Calculate Mean Squared Error (MSE): Average the squared errors.
MSE=41+1+4+4=410=2.5
The MSE is 2.5 degrees Celsius squared.
Calculate Root Mean Squared Error (RMSE): Take the square root of the MSE.
RMSE=MSE=2.5≈1.58
The RMSE is approximately 1.58 degrees Celsius. This tells us that the model's temperature predictions are typically off by about 1.58 degrees Celsius.
Comparing RMSE to MAE and MSE
It's helpful to compare RMSE with the other error metrics we've discussed:
MAE: Measures the average absolute error. Less sensitive to large errors than RMSE. Units are the same as the target variable.
MSE: Measures the average squared error. More sensitive to large errors due to squaring. Units are the square of the target variable's units.
RMSE: Measures the square root of the average squared error. Sensitive to large errors (like MSE). Units are the same as the target variable (like MAE), making it more interpretable than MSE.
Error metrics calculated for the temperature prediction example. MAE is 1.5°C, MSE is 2.5°C², and RMSE is approximately 1.58°C. Notice RMSE provides an error magnitude similar to MAE but incorporates the effect of squared errors.
Choosing between MAE and RMSE often depends on whether you want large errors to have a proportionally larger influence on the metric. If occasional large errors are acceptable, MAE might be suitable. If large errors are particularly problematic and should be heavily penalized, RMSE (or MSE) is often preferred. Because RMSE is in the original units, it's frequently chosen for reporting model performance in regression tasks.
An Introduction to Statistical Learning: With Applications in R, Gareth James, Daniela Witten, Trevor Hastie, Rob Tibshirani, 2021 (Springer) - This book is a widely used resource for statistical learning, explaining regression metrics like RMSE and their role in model assessment. (2nd edition)
Machine Learning (CS229) Lecture Notes, Andrew Ng, 2023 (Stanford University) - These widely recognized lecture notes offer a basic treatment of machine learning, including discussions of regression problems and associated error metrics.