拟合、探索并评估模型
一旦使用配方和模型定义了工作流,您就可以将数据拟合到该工作流中。此步骤使用训练数据集完成。随后使用测试集对训练好的模型进行评估。在本例中,目标变量是分类变量,并且您使用的是逻辑回归模型。因此,您将使用 F 值来评估测试集上的预测表现。来自上一个练习的 feature_selection_recipe、lr_model、attrition_wflow、train 和 test 已可供您使用。
已为您加载 tidyverse 和 tidymodels 包。
本练习是课程的一部分
R 中的降维
练习说明
- 使用训练数据拟合
attrition_wflow。 - 将测试集的预测结果添加回含有原始
Attrition值的测试数据中。 - 使用
f_meas()评估模型在测试数据上的表现。 - 显示
attrition_fit的模型估计。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Fit workflow to train data
attrition_fit <-
___ %>% ___(___ = ___)
# Add the test predictions to the test data
attrition_pred_df <- ___(___, ___) %>%
bind_cols(___ %>% select(___))
# Evaluate F score
___(___, ___, ___)
# Display model estimates
___(___)