基準模型
延續使用 attrition_num 資料集,你將用一個不做額外處理的基本 recipe 先建立基準模型,之後才能評估進一步特徵工程步驟的影響。已為你載入 attrition_num 資料、羅吉斯回歸模型 lr_model、使用者自訂的 class-evaluate() 函式,以及 train 與 test 分割。
本練習屬於課程
R 的特徵工程
練習說明
- 將模型與 recipe 打包成一個 workflow。
- 對已擬合的 workflow 使用 augment,使其可用於評估。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
lr_recipe_plain <- recipe(Attrition ~., data = train)
# Bundle the model and recipe
lr_workflow_plain <- workflow() %>%
___(lr_model) %>%
___(lr_recipe_plain)
lr_fit_plain <- lr_workflow_plain %>%
fit(train)
# Augment the fit workflow
lr_aug_plain <- lr_fit_plain %>%
___(___)
lr_aug_plain %>%
class_evaluate(truth = Attrition,estimate = .pred_class,
.pred_No)