开始使用免费开始使用

样本内 ROC 与 AUC

袋装树对训练集的结构拟合得有多好?是否比决策树更好?会不会过拟合?使用 ROC 和 AUC 是评估这些问题的好方法。

在本练习中,您将生成这些样本内预测,并计算其 ROC 和 AUC。请留意,可能会有一些意外发现!

已预加载上一个练习的结果 model_bagged,以及训练数据 customers_train

本练习是课程的一部分

R 中的树模型机器学习

查看课程

练习说明

  • 使用 model_bagged 在训练集上生成"概率"预测,并将其添加到训练集 tibble 中,结果保存为 predictions
  • 基于 predictions 这个 tibble 生成 ROC 曲线并绘图。
  • 计算 predictions 这个 tibble 的 AUC。

交互式实操练习

通过完成这段示例代码来试试这个练习。

# Predict on training set and add to training set
predictions <- ___(___,
                   new_data = ___, 
                   type = "___") %>% 
    bind_cols(___)

# Create and plot the ROC curve
roc_curve(___,
          estimate = ___,
          truth = ___) %>% autoplot()

# Calculate the AUC
___(predictions,
    estimate = ___, 
    truth = ___)
编辑并运行代码