开始使用免费开始使用

混淆矩阵

当响应变量只有两个结果时(如流失与否),评估模型好坏就看两点:"在客户确实流失的样本中,模型正确预测了多少?"以及"在客户未流失的样本中,模型正确预测了多少?"。这些可以通过生成混淆矩阵并据此计算汇总指标来得到。马赛克图是可视化这些结果的自然方式。

已提供 churnmdl_churn_vs_both_inter;已加载 dplyryardstick

本练习是课程的一部分

R 中级回归

查看课程

交互式实操练习

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

# Get the actual responses from churn
actual_response <- ___

# Get the predicted responses from the model
predicted_response <- ___

# Get a table of these values
outcomes <- ___

# Convert the table to a conf_mat object
confusion <- ___

# See the result
confusion
编辑并运行代码