開始使用免費開始

step_poly()

既然已經有基準模型,現在可以在所有數值型特徵上加入多項式轉換,來比較模型效能。

attrition_num 資料、羅吉斯迴歸 lr_model、使用者自訂的 class-evaluate() 函式,以及 traintest 的切分都已為你載入。

本練習屬於課程

R 的特徵工程

檢視課程

練習說明

  • 對所有數值型預測變數加入多項式轉換。
  • 將 workflow 擬合到訓練資料。

動手互動練習

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

lr_recipe_poly <- 
  recipe(Attrition ~., data = train) %>%

# Add a polynomial transformation to all numeric predictors
  ___

lr_workflow_poly <- workflow() %>%
  add_model(lr_model) %>%
  add_recipe(lr_recipe_poly)

# Fit workflow to the train data
lr_fit_poly <- ___ %>% fit(train)
lr_aug_poly <- lr_fit_poly %>% augment(test)
lr_aug_poly %>% class_evaluate(truth = Attrition, estimate = .pred_class,.pred_No)
編輯並執行程式碼