r - 如何在 ROCit 中计算 ROC?
问题描述
我想用 ROCit 来创建 ROC 曲线。我可以改变计算 ROC 曲线的方向(高值与健康有关)吗?
解决方案
install.packages("ROCit")
require(ROCit)
由于问题中没有示例,我将从文档中的示例开始,?rocit
如果我误解了您的问题,请告诉我。
# Load some example data
data("Diabetes")
# Calculate some ROC/validation data
roc_empirical <- rocit(score = Diabetes$chol, class = Diabetes$dtest,
negref = "-") # default method empirical
roc_binormal <- rocit(score = Diabetes$chol, class = Diabetes$dtest,
negref = "-", method = "bin")
# Summarize and plot the results
summary(roc_empirical) #60/329
summary(roc_binormal)
plot(roc_empirical)
plot(roc_binormal, col = c("#00BA37", "#F8766D"),
legend = FALSE, YIndex = FALSE)
我们可以查看summary(roc_empirical)
基线的输出:
Empirical ROC curve Number of postive responses : 60 Number of negative responses : 329 Area under curve : 0.652684903748734
现在,如果我理解(?)你只是想翻转参考值的含义/方向,在这种情况下是Diabetes$dtest
?
我们可以使用negref
参数来完成此操作:
roc_empirical <- rocit(score = Diabetes$chol, class = Diabetes$dtest,
negref = "+") # default method empirical
roc_binormal <- rocit(score = Diabetes$chol, class = Diabetes$dtest,
negref = "+", method = "bin")
summary(roc_empirical)
summary(roc_binormal)
plot(roc_empirical)
plot(roc_binormal, col = c("#00BA37", "#F8766D"),
legend = FALSE, YIndex = FALSE)
我们可以将结果summary(roc_empirical)
与我们之前看到的结果进行比较,发现它是“翻转”的:
Empirical ROC curve Number of postive responses : 329 Number of negative responses : 60 Area under curve : 0.353850050658561
当然,您也可以重新编码有问题的列。
这就是你所需要的吗?
推荐阅读
- javascript - 在购物车中隐藏特定产品 ID 的“确认”支付网关
- python - 使用 Chromedriver 遍历多个页面
- javascript - 如何在构建新的 Nuxt 应用程序时推出生产
- azure - 添加环境参数为 Azure Synapse
- javascript - 使用 CRA 时如何调整 babel 加载器以正确导入名为 macro.js 的模块
- java - Concat optaplanner 约束流
- laravel - 如何在laravel中使用带有where条件的group by从同一个表中获取记录?
- php - Elastic Beanstalk - 升级后替换 .htaccess 为 nginx
- html - 为什么项目没有占据整个宽度?
- typescript - 打字稿“运算符'+'不能应用于类型'(()=>任何)”