R 中的監督式學習:回歸
Nina Zumel and John Mount
Win-Vector, LCC
多個多樣的決策樹取平均
cnt ~ hr + holiday + workingday +
weathersit + temp + atemp + hum + windspeed

model <- ranger(fmla, bikesJan,
num.trees = 500,
respect.unordered.factors = "order")
formula、datanum.trees(預設 500)-建議至少 200mtry-每個節點要嘗試的變數數量respect.unordered.factors-建議設為 "order"model
Ranger result
...
OOB prediction error (MSE): 3103.623
R squared (OOB): 0.7837386
隨機森林會回傳樣本外效能的估計值。
bikesFeb$pred <- predict(model, bikesFeb)$predictions
predict() 輸入:
可從元素 predictions 取得預測值。
計算 RMSE:
bikesFeb %>%
mutate(residual = cnt - pred) %>%
summarize(rmse = sqrt(mean(residual^2)))
rmse
1 67.15169
| Model | RMSE |
|---|---|
| Quasipoisson | 69.3 |
| Random forests | 67.15 |


R 中的監督式學習:回歸