啊啊啊啊啊吖

2018-10-16   阅读量: 1708

数据分析师 R语言 机器学习

决策树画roc曲线的折点问题

扫码加入数据分析学习群

使用的是pROC包,关于roc()的参数我有点疑惑,modelroc <- roc(my第一个mydata.testy是实际数据里y变量的值,res_cost是我使用C50包构建决策树之后用predict.C5.0函数得到的预测结果,这两个都是factor的vector应该是,然后直接运行的话报错:第二个参数必须是numeric或者有序的,我就用as.numeric把res_cost转换成数字最后得到的图像是一条直线没有折点,如何设置更多的折点?

tree <- rpart(HCAI ~ hospital + age + gender + admseason + low_protein + UC + UN + UCN + UCL + UNL + LOS + fever + LOSICU + surnum + preoperative + postoperative + postoperative_ant + postoperative_antD + bacterial_culture + antibiotic + antibioticD + comb_ant + comb_antD + spec_ant + spec_antD  + sing_antD + doub_antD + Trip_antD + blood_exam + abblood + uri_exam + aburi + ventilatorD + ventilatorT + cvcD + cvcT + uriD + uriT + add, method = "class", data = LR_train)
tree

#ROC曲线的绘制
library(pROC)
froc <- roc(LR_trainHCAI,treey)
HCAI,treey)
froc
plot(froc, print.auc = TRUE, auc.polygon = TRUE, legacy.axes = TRUE,
     grid = c(0.1, 0.2), grid.col = c("green", "red"), max.auc.polygon = TRUE,  
     auc.polygon.col = "skyblue", xlab = "1-specificity", ylab = "sensitivity")
ci(froc)
115.7926 4 0 关注作者 收藏

评论(0)


暂无数据

推荐课程

推荐帖子