建立 recipe 物件
在上一章中,你使用 telecom_df 資料中的部分預測變數來擬合一個邏輯斯迴歸模型。這個資料集包含電信公司客戶的資訊,目標是預測他們是否會取消服務。
在本練習中,你會使用 recipes 套件,對電信資料裡的 avg_call_mins 與 avg_intl_mins 變數進行對數轉換。這能縮小這些變數的取值範圍,並可能讓其分佈更對稱,進而提升你的邏輯斯迴歸模型的準確度。
本練習屬於課程
在 R 中使用 tidymodels 建立模型
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Specify feature engineering recipe
telecom_log_rec <- recipe(___,
data = ___) %>%
# Add log transformation step for numeric predictors
___(___, ___, base = 10)
# Print recipe object
telecom_log_rec