step_percentile()
การแปลงตัวแปรเชิงตัวเลขด้วย Percentile Transformation จะส่งผลต่อประสิทธิภาพของโมเดลอย่างไร? มาลองดูกัน!
ข้อมูล attrition_num, โมเดล Logistic Regression lr_model, ฟังก์ชัน class_evaluate() ที่กำหนดเอง รวมถึงชุดข้อมูล train และ test ถูกโหลดไว้ให้แล้ว
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Feature Engineering in R
คำแนะนำการฝึกหัด
- ใช้ Percentile Transformation กับตัวทำนายเชิงตัวเลขทั้งหมด
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# 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)