liveBook · Manning

Root mean squared error

As explained in Grokking Machine Learning

A regression metric equal to the square root of the average squared difference between observed and predicted target values.

Root mean squared error (RMSE) is the square root of the average of squared differences between observed and predicted values: RMSE = √mean((observed − predicted)²). Averaging makes errors comparable across datasets of different sizes; taking the square root returns the measure to the target’s units. section 3.4

For house prices, an RMSE of $10,000 suggests predictions are off by around $10,000. A large RMSE is not automatically proof of a bad model: outliers or missing features may contribute to it. section 3.4 section 3.5

Comparing models on test data

In a polynomial-regression example, testing RMSE is 699.03 without regularization, 10.08 with L1 regularization, and 3.41 with L2 regularization. The lower L2 result indicates better performance in this comparison. section 4.6

def rmse(labels, predictions):
   n = len(labels)
   differences = np.subtract(labels, predictions)
   return np.sqrt(1.0/n * (np.dot(differences, differences)))

See a short Python function that calculates RMSE from labels and predictions. section 3.4

How Grokking Machine Learning covers it

How deep it goes
Defines RMSE and explains its units and interpretation, but stops short of deriving the measure.
Examples
Uses house-price predictions, a Hyderabad housing model, and polynomial-regression testing results.
What you can do after
Evaluate regression predictions by interpreting error in target units and comparing testing RMSE across models.
How it connects
Links RMSE with mean squared error, mean absolute error, linear regression, and regularization.

Also explained in

Compare how 7 books explain root mean squared error →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Machine Learning. The section links point to the parts of the book it draws on.