การ Fit และประเมินโมเดล
หลังจากจัดการค่าที่หายไปและสร้าง dummy variables แล้ว ถึงเวลาประเมินประสิทธิภาพของโมเดลกัน!
ชุดข้อมูล attrition พร้อมด้วยการแบ่ง test และ train, lr_recipe และ logistic_model() ที่ประกาศไว้ ถูกโหลดให้พร้อมใช้งานแล้ว
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
Feature Engineering in R
คำแนะนำการฝึกหัด
- รวมโมเดลและ recipe เข้าด้วยกันใน workflow
- Fit workflow กับข้อมูล train
- สร้าง augmented data frame สำหรับประเมินประสิทธิภาพ
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Bundle model and recipe in workflow
lr_workflow <- ___() %>%
add_model(lr_model) %>%
add_recipe(lr_recipe)
# Fit workflow to the train data
lr_fit <- ___(lr_workflow, data = train)
# Generate an augmented data frame for performance assessment
lr_aug <- lr_fit %>% ___(test)
lr_aug %>% roc_curve(truth = Attrition, .pred_No) %>% autoplot()
bind_rows(lr_aug %>% roc_auc(truth = Attrition, .pred_No),
lr_aug %>% accuracy(truth = Attrition, .pred_class))