開始使用免費開始

擬合與評估模型

現在你已處理遺漏值並建立虛擬變數,是時候評估模型的效能了!

attrition 資料集,以及 testtrain 的分割、lr_recipe,還有你宣告的 logistic_model() 都已為你載入。

本練習屬於課程

R 的特徵工程

檢視課程

練習說明

  • 在 workflow 中打包模型與 recipe。
  • 將 workflow 擬合到訓練資料。
  • 產生用於效能評估的增廣資料框。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# 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))
編輯並執行程式碼