均方根誤差(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...