Root Mean Squared Error (RMSE)

Supervised Learning in R: Regression

Nina Zumel and John Mount

Win-Vector LLC

What is Root Mean Squared Error (RMSE)?

$$ RMSE = \sqrt{\overline{(y-pred)^2}} $$

where

  • $y - pred$: the error, or residuals vector
  • $\overline{(y-pred)^2}$: mean value of $(y-pred)^2$
Supervised Learning in R: Regression

RMSE of the Home Sales Price Model

# Calculate error
err <- houseprices$prediction - houseprices$price
  • price: column of actual sale prices (in thousands)
  • prediction: column of predicted sale prices (in thousands)
Supervised Learning in R: Regression

RMSE of the Home Sales Price Model

# Calculate error
err <- houseprices$prediction - houseprices$price

# Square the error vector
err2 <- err^2
Supervised Learning in R: Regression

RMSE of the Home Sales Price Model

# Calculate error
err <- houseprices$prediction - houseprices$price

# Square the error vector
err2 <- err^2

# Take the mean, and sqrt it
(rmse <- sqrt(mean(err2)))
58.33908
  • $RMSE \approx 58.3$
Supervised Learning in R: Regression

Is the RMSE Large or Small?

# Take the mean, and sqrt it
(rmse <- sqrt(mean(err2)))
58.33908
# The standard deviation of the outcome
(sdtemp <- sd(houseprices$price))
135.2694
  • $RMSE \approx 58.3$
  • $sd(price) \approx 135$
Supervised Learning in R: Regression

Let's practice!

Supervised Learning in R: Regression

Preparing Video For Download...