樣本內 ROC 與 AUC
袋裝樹在你的訓練集上能多好地捕捉資料結構?是否比決策樹更好?會不會過度擬合?使用 ROC 與 AUC 是評估這些問題的好方法。
在這個練習中,你將產生樣本內預測,並計算它們的 ROC 與 AUC。注意看,可能會有意外發現!
已預先載入上一個練習的結果 model_bagged,以及訓練資料 customers_train。
本練習屬於課程
R 的樹狀模型機器學習
練習說明
- 使用
model_bagged搭配訓練集產生「機率」預測,並把結果加入訓練集的 tibble,將其儲存為predictions。 - 針對
predictions這個 tibble 產生 ROC 曲線並繪圖。 - 計算
predictions這個 tibble 的 AUC。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Predict on training set and add to training set
predictions <- ___(___,
new_data = ___,
type = "___") %>%
bind_cols(___)
# Create and plot the ROC curve
roc_curve(___,
estimate = ___,
truth = ___) %>% autoplot()
# Calculate the AUC
___(predictions,
estimate = ___,
truth = ___)