Root Mean Squared Error (RMSE)

Description

While MSE is measured in units that are the square of the target value, the RMSE delivers the size of the error in the same units as the original data. RMSE is easier to interpret than MSE, which is why it’s more commonly used.

\[\text{RMSE} = \sqrt{\frac{1}{n} \sum_{i=1}^{n} (y_i - \hat{y}_i)^2}\]

where:

  • ( n ) is the number of observations.

  • ( y_i ) is the actual value.

  • ( hat{y}_i ) is the predicted value.

Tools and Libraries

Python

To compute the RMSE between the actual values and predicted values, the following example can be used.

Install scikit-learn via this command:

pip install -U scikit-learn
from sklearn.metrics import mean_squared_error
import math 

y_true = [5, 0.2, 8, -0.3]
y_pred = [6, 0.0, 7, 0.0]

MSE = mean_squared_error(y_true, y_pred)
RMSE = math.sqrt(MSE)

print(f"The RMSE is: {RMSE}")

MATLAB

C++

Literature