訓練、探索並評估模型
當你以 recipe 與模型定義好 workflow 後,就能把資料套用到該 workflow。這一步會使用訓練資料集。接著用測試集來評估已訓練的模型。在這個例子中,目標變數是類別型,且你使用的是邏輯斯迴歸模型。因此你會用 F measure 來評估測試預測。先前練習中的 feature_selection_recipe、lr_model、attrition_wflow、train 與 test 都可供你使用。
已為你載入 tidyverse 與 tidymodels 套件。
本練習屬於課程
R 的降維
練習說明
- 使用訓練資料來訓練
attrition_wflow。 - 將測試預測加入含有原始
Attrition值的測試資料中。 - 使用
f_meas()評估模型在測試資料上的效能。 - 顯示
attrition_fit的模型估計值。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Fit workflow to train data
attrition_fit <-
___ %>% ___(___ = ___)
# Add the test predictions to the test data
attrition_pred_df <- ___(___, ___) %>%
bind_cols(___ %>% select(___))
# Evaluate F score
___(___, ___, ___)
# Display model estimates
___(___)