Learn R Programming

TDMR (version 2.2)

tdmROCRbase: Single plot of ROC, lift or other chart for a TDMclassifier object.

Description

Single plot of ROC, lift or other chart for a TDMclassifier object.

Usage

tdmROCRbase(
  x,
  dataset = "validation",
  nRun = 1,
  typ = "ROC",
  noPlot = FALSE,
  ...
)

Arguments

x

return value from a prior call to tdmClassifyLoop, an object of class TDMclassifier.

dataset

["validation"] which part of the data to use, either "training" or "validation"

nRun

[1] if x contains multiple runs, which run to show (1,...,Opts(x)$NRUN)

typ

["ROC"] which chart type, one out of ("ROC","lift","precRec") for (ROC, lift, precision-recall)-chart (see performance in package ROCR for more details):

  • "ROC": receiver operating curve, TPR vs. FPR, with TPR=TP/(TP+FN)=TP/P and FPR=FP/(FP+TN)=FP/N (true and false positive rate).

  • "lift": lift chart, LIFT vs. RPP, with LIFT=TPR/RPR with random positive rate RPR=P/(P+N) and RPP=(TP+FP)/(P+N) (rate of pos. predictions).

  • "precRec": precision-recall-chart, PREC vs. RECALL, with PREC=TP/(TP+FP) and RECALL=TP/P (same as TPR).

noPlot

[FALSE] if TRUE, suppress the plot, return only the area under curve

...

currently not used

Value

The area between the curve and the bottom line y=0.0 in the case of typ=="ROC" | typ=="precRec" or the area between the curve and the bottom line y=1.0 in the case of typ=="lift". If object x does not contain a prediction score, a warning is issued and the return value is NULL.

See Also

tdmClassifyLoop tdmROCR.TDMclassifier

Examples

Run this code
# NOT RUN {
#*# --------- demo/demo05ROCR.r ---------
#*# Run task SONAR with "area under ROC curve" as performance measure (rgain.type="arROC").
#*# Other settings are similar to demo01-1sonar.r (level 1 of TDMR).
#*# Finally, plot ROC curve for validataion data set and 
#+#          plot lift chart for training data set
#*#
    path <- paste(find.package("TDMR"), "demo02sonar",sep="/");
    #path <- paste("../inst", "demo02sonar",sep="/");

    source(paste(path,"main_sonar.r",sep="/"));    # defines readTrnSonar

    controlDM <- function() {
      #
      # settings for the DM process (former sonar_00.apd file): 
      # (see ?tdmOptsDefaultsSet for a complete list of all default settings 
      # and many explanatory comments)
      #
      opts = list(path = path,
                  dir.data = "data",            # relative to path
                  filename = "sonar.txt",
                  READ.TrnFn = readTrnSonar,    # defined in main_sonar.r
                  data.title = "Sonar Data",
                  NRUN =  1,
                  rgain.type = "arROC",
                  VERBOSE = 2
      );
      opts <- setParams(opts, defaultOpts(), keepNotMatching = TRUE);
    }
    
    opts <- controlDM();
    result <- main_sonar(opts);     
    
    tdmGraphicNewWin(opts);
    cat("Area under ROC-curve for validation data set: ",
        tdmROCRbase(result),"\n");                                # side effect: plot ROC-curve
    tdmGraphicNewWin(opts);
    cat("Area under lift curve for  training data set: ",
        tdmROCRbase(result,dataset="training",typ="lift"),"\n");  # side effect: plot lift chart
    
# }

Run the code above in your browser using DataLab