预测酒店预订
您刚加入一家酒店与旅游研究公司,第一项任务是构建一个模型,用来预测某次酒店入住是否包含儿童。 为训练模型,您将使用 Antonio、Almeida 和 Nunes(2019)发布的酒店预订需求数据集的一个修改版本。您将数据限定为以下特征:
features <- c('hotel', 'adults',
'children', 'meal',
'reserved_room_type',
'customer_type',
'arrival_date')
数据已加载为 hotels,并提供了相应的 test 与 train 划分,模型已声明为 lr_model <- logistic_reg()。
您将使用准确率和 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(___)