開始使用免費開始

預測飯店訂房

你剛加入一家旅遊與飯店產業研究公司,你的第一個任務是建立一個模型,用來預測某次住宿是否會包含兒童。 為了訓練模型,你會使用 Antonio、Almeida 與 Nunes(2019)整理過的飯店訂房需求資料集的修改版。你將資料限制在以下這些特徵:

features <- c('hotel', 'adults', 
              'children', 'meal',
              'reserved_room_type', 
              'customer_type', 
              'arrival_date')

資料已載入為 hotels,並提供對應的 testtrain 切分;模型也已宣告為 lr_model <- logistic_reg()

你將以準確率(accuracy)與 ROC 曲線下面積(AUC)來評估模型效能。

本練習屬於課程

R 的特徵工程

檢視課程

動手互動練習

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

lr_recipe <- 
  recipe(children ~., data = train) %>%
# Generate "day of the week", "week" and "month" features

  step_date(arrival_date, features = c(___, ___, ___)) %>%

# Create dummy variables for all nominal predictors
  step_dummy(___)
編輯並執行程式碼