step_percentile()
把數值型變數做百分位數轉換,會如何影響模型效能?動手試試看!
已為你載入 attrition_num 資料、羅吉斯回歸 lr_model、使用者自訂的 class-evaluate() 函式,以及 train 和 test 切分。
本練習屬於課程
R 的特徵工程
練習說明
- 對所有數值型自變數套用百分位數轉換。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Add percentile tansformation to all numeric predictors
lr_recipe_perc <-
recipe(Attrition ~., data = train) %>%
___
lr_workflow_perc <-
workflow() %>%
add_model(lr_model) %>%
add_recipe(lr_recipe_perc)
lr_fit_perc <- lr_workflow_perc %>% fit(train)
lr_aug_perc <- lr_fit_perc %>% augment(test)
lr_aug_perc %>% class_evaluate(truth = Attrition,
estimate = .pred_class,.pred_No)