R : Copyright 2005, The R Foundation for Statistical Computing Version 2.1.1 (2005-06-20), ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for a HTML browser interface to help. Type 'q()' to quit R. > ### *
> ### > attach(NULL, name = "CheckExEnv") > assign(".CheckExEnv", as.environment(2), pos = length(search())) # base > ## add some hooks to label plot pages for base and grid graphics > setHook("plot.new", ".newplot.hook") > setHook("persp", ".newplot.hook") > setHook("grid.newpage", ".gridplot.hook") > > assign("cleanEx", + function(env = .GlobalEnv) { + rm(list = ls(envir = env, all.names = TRUE), envir = env) + RNGkind("default", "default") + set.seed(1) + options(warn = 1) + delayedAssign("T", stop("T used instead of TRUE"), + assign.env = .CheckExEnv) + delayedAssign("F", stop("F used instead of FALSE"), + assign.env = .CheckExEnv) + sch <- search() + newitems <- sch[! sch %in% .oldSearch] + for(item in rev(newitems)) + eval(substitute(detach(item), list(item=item))) + missitems <- .oldSearch[! .oldSearch %in% sch] + if(length(missitems)) + warning("items ", paste(missitems, collapse=", "), + " have been removed from the search path") + }, + env = .CheckExEnv) > assign("..nameEx", "__{must remake R-ex/*.R}__", env = .CheckExEnv) # for now > assign("ptime", proc.time(), env = .CheckExEnv) > grDevices::postscript("ROCR-Examples.ps") > assign("par.postscript", graphics::par(no.readonly = TRUE), env = .CheckExEnv) > options(contrasts = c(unordered = "contr.treatment", ordered = "contr.poly")) > options(warn = 1) > library('ROCR') Loading required package: gplots Loading required package: gdata Loading required package: gtools Loading required package: gtools Attaching package: 'gplots' The following object(s) are masked from package:stats : lowess > > assign(".oldSearch", search(), env = .CheckExEnv) > assign(".oldNS", loadedNamespaces(), env = .CheckExEnv) > cleanEx(); ..nameEx <- "ROCR.hiv" > > ### * ROCR.hiv > > flush(stderr()); flush(stdout()) > > ### Name: ROCR.hiv > ### Title: Data set: Support vector machines and neural networks applied to > ### the prediction of HIV-1 coreceptor usage > ### Aliases: ROCR.hiv > ### Keywords: datasets > > ### ** Examples > > data(ROCR.hiv) > attach(ROCR.hiv) > pred.svm <- prediction(hiv.svm$predictions, hiv.svm$labels) > perf.svm <- performance(pred.svm, 'tpr', 'fpr') > pred.nn <- prediction(hiv.nn$predictions, hiv.svm$labels) > perf.nn <- performance(pred.nn, 'tpr', 'fpr') > plot(perf.svm, lty=3, col="red",main="SVMs and NNs for prediction of + HIV-1 coreceptor usage") > plot(perf.nn, lty=3, col="blue",add=TRUE) > plot(perf.svm, avg="vertical", lwd=3, col="red", + spread.estimate="stderror",plotCI.lwd=2,add=TRUE) > plot(perf.nn, avg="vertical", lwd=3, col="blue", + spread.estimate="stderror",plotCI.lwd=2,add=TRUE) > legend(0.6,0.6,c('SVM','NN'),col=c('red','blue'),lwd=3) > > > > cleanEx(); ..nameEx <- "ROCR.simple" > > ### * ROCR.simple > > flush(stderr()); flush(stdout()) > > ### Name: ROCR.simple > ### Title: Data set: Simple artificial prediction data for use with ROCR > ### Aliases: ROCR.simple > ### Keywords: datasets > > ### ** Examples > > # plot a ROC curve for a single prediction run > # and color the curve according to cutoff. > data(ROCR.simple) > pred <- prediction(ROCR.simple$predictions, ROCR.simple$labels) > perf <- performance(pred,"tpr","fpr") > plot(perf,colorize=TRUE) > > > > cleanEx(); ..nameEx <- "ROCR.xval" > > ### * ROCR.xval > > flush(stderr()); flush(stdout()) > > ### Name: ROCR.xval > ### Title: Data set: Artificial cross-validation data for use with ROCR > ### Aliases: ROCR.xval > ### Keywords: datasets > > ### ** Examples > > # 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) > > > > cleanEx(); ..nameEx <- "performance" > > ### * performance > > flush(stderr()); flush(stdout()) > > ### Name: performance > ### Title: Function to create performance objects > ### Aliases: performance > ### Keywords: classif > > ### ** Examples > > ## computing a simple ROC curve (x-axis: fpr, y-axis: tpr) > library(ROCR) > data(ROCR.simple) > pred <- prediction( ROCR.simple$predictions, ROCR.simple$labels) > perf <- performance(pred,"tpr","fpr") > plot(perf) > > ## precision/recall curve (x-axis: recall, y-axis: precision) > perf1 <- performance(pred, "prec", "rec") > plot(perf1) > > ## sensitivity/specificity curve (x-axis: specificity, > ## y-axis: sensitivity) > perf1 <- performance(pred, "sens", "spec") > plot(perf1) > > > > cleanEx(); ..nameEx <- "plot-methods" > > ### * plot-methods > > flush(stderr()); flush(stdout()) > > ### Name: plot-methods > ### Title: Plot method for performance objects > ### Aliases: plot.performance plot-methods plot,performance-method > ### plot,performance,missing-method > ### Keywords: hplot > > ### ** Examples > > # plotting a ROC curve: > library(ROCR) > data(ROCR.simple) > pred <- prediction( ROCR.simple$predictions, ROCR.simple$labels ) > perf <- performance( pred, "tpr", "fpr" ) > plot( perf ) > > # To entertain your children, make your plots nicer > # using ROCR's flexible parameter passing mechanisms > # (much cheaper than a finger painting set) > par(bg="lightblue", mai=c(1.2,1.5,1,1)) > plot(perf, main="ROCR fingerpainting toolkit", colorize=TRUE, + xlab="Mary's axis", ylab="", box.lty=7, box.lwd=5, + box.col="gold", lwd=17, colorkey.relwidth=0.5, xaxis.cex.axis=2, + xaxis.col='blue', xaxis.col.axis="blue", yaxis.col='green', yaxis.cex.axis=2, + yaxis.at=c(0,0.5,0.8,0.85,0.9,1), yaxis.las=1, xaxis.lwd=2, yaxis.lwd=3, + yaxis.col.axis="orange", cex.lab=2, cex.main=2) > > > > graphics::par(get("par.postscript", env = .CheckExEnv)) > cleanEx(); ..nameEx <- "prediction" > > ### * prediction > > flush(stderr()); flush(stdout()) > > ### Name: prediction > ### Title: Function to create prediction objects > ### Aliases: prediction > ### Keywords: classif > > ### ** Examples > > # create a simple prediction object > library(ROCR) > data(ROCR.simple) > pred <- prediction(ROCR.simple$predictions,ROCR.simple$labels) > > > > ### *