开始使用免费开始使用

还能进一步简化模型吗?

删除变量 loan_amnt 后,AUC 还能进一步提升到 0.6548!得到的模型为:

log_4_remove_amnt <- glm(loan_status ~ grade + annual_inc + emp_cat, family = binomial, data = training_set) 

是否可以将逻辑回归模型再缩减到仅包含两个变量,同时不降低 AUC?本练习将带您检验这一点!

本练习是课程的一部分

R 中的信用风险建模

查看课程

练习说明

  • 仍然是在模型 log_4_remove_amnt 的基础上,每次删除一个变量。请记住应使用默认的链接函数(logit)。
  • 使用 predict() 为您创建的每个模型生成违约概率预测。
  • 分别为这 3 个模型计算 AUC,auc() 的第一个参数使用 test_set$loan_status,第二个参数使用对应模型的预测结果。
  • 为具有最高 AUC 的模型绘制 ROC 曲线,使用 plot(roc()),其中 roc() 的参数与最高 AUC 的 auc() 所用参数相同。请注意,相比 log_4_remove_amnt,AUC 也可能无法进一步提升。若该模型达到最高 AUC,则其预测结果已以 pred_4_remove_amnt 的名称加载到您的工作空间中。

交互式实操练习

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

# Build three models each time deleting one variable in log_4_remove_amnt
log_5_remove_grade <- glm(loan_status ~ annual_inc + emp_cat, family = binomial, data = training_set) 
log_5_remove_inc <- 
log_5_remove_emp <- 

# Make PD-predictions for each of the models
pred_5_remove_grade <- predict(log_5_remove_grade, newdata = test_set, type = "response")
pred_5_remove_inc <-
pred_5_remove_emp <-

# Compute the AUCs



# Plot the ROC-curve for the best model here
编辑并运行代码