R的ROC曲线置信区间
我创建了用于显示ROC曲线的置信区间的代码,均为logistic和随机森林。但是我想在X轴上具有1-特异性而不是特异性。 代码为
roc.list <- roc(test_df$extry ~ Logistic_Regression+Random_Forest)
ci.list <- lapply(roc.list, ci.se, specificities = seq(0, 1, l = 10))
dat.ci.list <- lapply(ci.list, function(ciobj)
data.frame(x = as.numeric(rownames(ciobj)),
lower = ciobj[, 1],
upper = ciobj[, 3]))
p <- ggroc(roc.list,legacy.axes=TRUE) + theme_minimal() + geom_abline(slope=1, intercept = 1, linetype = "dashed", alpha=0.7, color = "grey") + coord_equal()
for(i in 1:3) {
p <- p + geom_ribbon(
data = dat.ci.list[[i]],
aes(x = x, ymin = lower, ymax = upper),
fill = i + 1,
alpha = 0.2,
inherit.aes = F)
}
p
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设您正在使用
ggroc
函数从proc
软件包中使用。当您使用
laceacy.axes = true
运行ggroc
时,ggplot
函数在以下美学中调用:如@allan cameron 在评论中,您需要指定在x:x::
I assume you are using the
ggroc
function from thepROC
package.When you run
ggroc
withlegacy.axes=TRUE
, theggplot
function is called with the following aesthetics:As identified by @Allan Cameron in the comments, you need to specify compatible aesthetics that specify 1-specificity in x: