Root Mean Squared Error

Root mean squared error (RMSE) is a metric used to evaluate regression models. The RMSE of a model is the square root of the average squared difference between actual values and predicted values over all examples. More succinctly, RMSE is the square root of the mean squared error.

RMSE = 1 m βˆ‘ i = 1 m ( y i βˆ’ y ^ i ) 2

where:

  • m is the number of examples
  • yi is the actual value of the label of the ith example
  • Ε·i is the predicted value of the label of the ith example

The lower the RMSE, the better the model’s performance. The best possible RMSE is 0.

Computing root mean squared error in scikit-learn

import numpy as np
from sklearn.metrics import mean_squared_error

y_true = np.array([32, 38, 47, 58, 66, 73, 85, 91, 106, 116])
y_pred = np.array([32, 41, 50, 59, 68, 77, 86, 95, 104, 113])
rmse = mean_squared_error(y_true, y_pred, squared=False)

print(f"RMSE: {rmse:.2f}")
RMSE: 2.63

This page references the following sources:

Here are all the notes in this garden, along with their links, visualized as a graph.