r - How to extract average ROC curve predictions using ROCR? -
the rocr library in r offer ability plot average roc curve (right rocr reference manual):
library(rocr) library(rocr) data(rocr.xval) # plot roc curves several cross-validation runs (dotted # in grey), overlaid vertical average curve , boxplots # showing vertical spread around 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) lovely. unfortunately, there's seemingly no ability obtain average roc curve object/dataframe/etc. further statistical testing (say, proc). did research (albeit perhaps after fact), , found post:
i looked through rocr's code reveals following lines passing result plot:
performance_plots.r, (starting @ line 451)
## compute average curve perf.avg <- perf.sampled perf.avg@x.values <- list( rowmeans( data.frame( perf.avg@x.values))) perf.avg@y.values <- list(rowmeans( data.frame( perf.avg@y.values))) perf.avg@alpha.values <- list( alpha.values ) so, using trace function looked here (general suggestions debugging in r):
trace(.performance.plot.horizontal.avg, edit=true) i added following line performance_plots.r after lines listed above:
perf.rocr.avg <<- perf.avg # note double `<<` a horrible hack, yet works can plot perf.rocr.avg without problem. unfortunately, when using proc, can't compare averaged roc curve because requires proc roc object. that's fine, catch proc roc object requires original prediction , reference data create. far can tell, rocr averaging roc curves , not predictions, seems can't want out of rocr.
is there way reverse-engineer predictions averaged roc curve created rocr?

Comments
Post a Comment