ROCR
中的R
库提供了plot平均ROC曲线的功能(从ROCR reference manual开始):
library(ROCR)
library(ROCR)
data(ROCR.xval)
# plot ROC curves for several cross-validation runs (dotted
# in grey), overlaid by the vertical average curve and boxplots
# showing the vertical spread around the average.
data(ROCR.xval)
pred <- prediction(ROCR.xval$predictions, ROCR.xval$labels)
perf <- performance(pred,"tpr","fpr")
plot(perf,col="grey82",lty=3)
plot(perf,lwd=3,avg="vertical",spread.estimate="boxplot",add=TRUE)
可爱。不幸的是,似乎没有能力获得平均ROC曲线本身作为对象/数据框/等。进行进一步的统计检验(例如pROC
)。我确实做了一些研究(尽管可能是事实),但我发现了这篇文章:
我查看了ROCR的代码,发现了以下将结果传递到绘图的行:
performance_plots.R
,(从第451行开始)
## compute average curve
perf.avg <- perf.sampled
[email protected] <- list( rowMeans( data.frame( [email protected])))
[email protected] <- list(rowMeans( data.frame( [email protected])))
[email protected] <- list( alpha.values )
所以,使用trace
功能,我在这里查找了[General suggestions for debugging in R):
trace(.performance.plot.horizontal.avg, edit=TRUE)
我在上面列出的行之后在performance_plots.R
中添加了以下行:
perf.rocr.avg <<- perf.avg # note the double `<<`
一个可怕的骇客,但它可以正常工作,因为我可以毫无问题地绘制perf.rocr.avg
。不幸的是,使用pROC
时,我无法比较平均ROC曲线,因为它需要pROC
roc
对象。很好,但是要注意的是pROC
roc
对象需要创建原始预测和参考数据。据我所知,ROCR
是对ROC曲线本身求平均值,而不是对预测求平均值,所以看来我无法从ROCR
中得到想要的结果。
是否有一种方法可以根据ROCR
创建的平均ROC曲线对预测进行逆向工程?
我遇到了与您相同的问题。我认为,ROCR软件包生成的平均ROC只是分配了数值,而缺少其他统计属性(例如置信区间)。这意味着使用平均ROC进行统计可能没有意义,这就是为什么无法通过PRoc包中的(tpr,fpr)列表生成roc对象的原因。但是,我找到了一篇论文来解决这个问题,即平均ROC之间的比较。标题为“相关接收机工作特性曲线下的平均面积:基于广义两样本Wilcoxon统计的非参数方法”。希望对您有所帮助。