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
| 模型 | RMSE |
|---|---|
| Quasipoisson | 69.3 |
| 随机森林 | 67.15 |


R 中的监督学习:回归