完成特徵工程管線
recipes 套件用來把多個特徵工程步驟封裝成單一物件,讓你在機器學習流程中更容易維護資料轉換。
在這個練習中,你將訓練一個特徵工程管線,為電信資料做好建模前的準備。
telecom_df tibble,以及你在前面練習建立的 telecom_training 和 telecom_test 資料集,已載入到你的工作空間中。
本練習屬於課程
在 R 中使用 tidymodels 建立模型
練習說明
- 建立一個 recipe,使用訓練資料中的所有預測變數來預測
canceled_service。 - 使用 0.8 的門檻值移除彼此相關的預測變數。
- 標準化所有數值型預測變數。
- 為所有名目型預測變數建立虛擬變數。
- 在訓練資料上訓練你的 recipe,並將其套用到測試資料。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Create a recipe that predicts canceled_service using the training data
telecom_recipe <- ___ %>%
# Remove correlated predictors
___ %>%
# Normalize numeric predictors
___ %>%
# Create dummy variables
___
# Train your recipe and apply it to the test data
telecom_recipe %>%
___ %>%
___