基线
继续使用 attrition_num 数据集,您将用一个最简单的 recipe 创建一个基线,以评估后续特征工程步骤的效果。attrition_num 数据、逻辑回归模型 lr_model、用户自定义的 class-evaluate() 函数,以及 train 和 test 划分已为您加载。
本练习是课程的一部分
R 中的特征工程
练习说明
- 将模型和 recipe 打包到一个 workflow 中。
- 对拟合后的 workflow 使用 augment,使其准备好用于评估。
交互式实操练习
通过完成这段示例代码来试试这个练习。
lr_recipe_plain <- recipe(Attrition ~., data = train)
# Bundle the model and recipe
lr_workflow_plain <- workflow() %>%
___(lr_model) %>%
___(lr_recipe_plain)
lr_fit_plain <- lr_workflow_plain %>%
fit(train)
# Augment the fit workflow
lr_aug_plain <- lr_fit_plain %>%
___(___)
lr_aug_plain %>%
class_evaluate(truth = Attrition,estimate = .pred_class,
.pred_No)