開始使用免費開始

設定你的 workflow

你想檢視單獨使用 JobRole 是否能預測 Attrition。由於 JobRole 是 factor,你打算用 Bayes 編碼器把它轉成可在模型中使用的數值表示。

embed 套件以及來自 attrition 資料集的 testtrain 切分已載入到你的工作區。

本練習屬於課程

R 的特徵工程

檢視課程

練習說明

  • 使用 Bayes 編碼器建立一個 recipe。
  • 用 workflow 將模型與 recipe 打包在一起。

動手互動練習

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

lr_model <- logistic_reg()
# Create recipe using the Bayes encoder
lr_recipe_glm <- 
  recipe(Attrition ~ JobRole, data = train) %>%
  ___(JobRole, outcome = ___(Attrition))

# Bundle with workflow
lr_workflow_glm <-
  workflow() %>%
  add_model(lr_model) %>%
  add_recipe(___)

lr_workflow_glm
編輯並執行程式碼