R语言如何计算cutoff值:test_prob - predictf1 newdata =test type = fittedrocobj - roctest$分组 test_prob
在R语言中,可以使用以下方法计算cutoff值:
- 找到最佳的cutoff值:
可以使用函数“coords(rocobj, "best", ret=c("threshold"))”来找到最佳的cutoff值。该函数会返回最佳的cutoff值。
- 找到指定敏感度或特异度下的cutoff值:
可以使用函数“coords(rocobj, x = 1-specificity, ret = c("threshold"))”来找到指定特异度下的cutoff值。其中,1-specificity表示假阳性率,x为指定的假阳性率,ret为返回值类型,可以选择"threshold"、"specificity"或"sensitivity"。
同样地,可以使用函数“coords(rocobj, y = sensitivity, ret = c("threshold"))”来找到指定敏感度下的cutoff值。其中,sensitivity为真阳性率,y为指定的真阳性率。
需要注意的是,以上函数均需要先通过roc()函数计算出ROC曲线对象rocobj,具体可以参考代码中的“rocobj <- roc(test$分组, test_prob)”部分
原文地址: https://www.cveoy.top/t/topic/fIKr 著作权归作者所有。请勿转载和采集!