均方根误差(RMSE)

R 中的监督学习:回归

Nina Zumel and John Mount

Win-Vector LLC

什么是均方根误差(RMSE)?

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

其中:

  • $y - pred$:误差(残差)向量
  • $\overline{(y-pred)^2}$:$(y-pred)^2$ 的均值
R 中的监督学习:回归

房价模型的 RMSE

# Calculate error
err <- houseprices$prediction - houseprices$price
  • price:实际销售价格列(单位:千)
  • prediction:预测销售价格列(单位:千)
R 中的监督学习:回归

房价模型的 RMSE

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

# Square the error vector
err2 <- err^2
R 中的监督学习:回归

房价模型的 RMSE

# 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$
R 中的监督学习:回归

RMSE 大还是小?

# 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$
R 中的监督学习:回归

开始练习吧!

R 中的监督学习:回归

Preparing Video For Download...