Last data update: 2014.03.03

R: Compute the receiver operating characteristic (ROC) curve.
rocR Documentation

Compute the receiver operating characteristic (ROC) curve.

Description

This function computes the receiver operating characteristic (ROC) curve required for the auc function and the plot function.

Usage

  roc(predictions, labels)

Arguments

predictions

A numeric vector of classification probabilities (confidences, scores) of the positive event.

labels

A factor of observed class labels (responses) with the only allowed values {0,1}.

Value

A list containing the following elements:

cutoffs

A numeric vector of threshold values

fpr

A numeric vector of false positive rates corresponding to the threshold values

tpr

A numeric vector of true positive rates corresponding to the threshold values

Author(s)

Authors: Michel Ballings and Dirk Van den Poel, Maintainer: Michel.Ballings@UGent.be

References

Ballings, M., Van den Poel, D., Threshold Independent Performance Measures for Probabilistic Classifcation Algorithms, Forthcoming.

See Also

sensitivity, specificity, accuracy, roc, auc, plot

Examples

data(churn)

roc(churn$predictions,churn$labels)

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

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 an HTML browser interface to help.
Type 'q()' to quit R.

> library(AUC)
AUC 0.3.0
Type AUCNews() to see the change log and ?AUC to get an overview.
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/AUC/roc.Rd_%03d_medium.png", width=480, height=480)
> ### Name: roc
> ### Title: Compute the receiver operating characteristic (ROC) curve.
> ### Aliases: roc
> 
> ### ** Examples
> 
> data(churn)
> 
> roc(churn$predictions,churn$labels)
$cutoffs
  [1] 1.000 1.000 0.972 0.968 0.964 0.960 0.932 0.910 0.908 0.902 0.896 0.890
 [13] 0.882 0.878 0.866 0.862 0.856 0.840 0.812 0.800 0.784 0.770 0.760 0.758
 [25] 0.750 0.748 0.740 0.734 0.714 0.712 0.698 0.694 0.682 0.676 0.672 0.664
 [37] 0.650 0.648 0.636 0.612 0.596 0.592 0.586 0.568 0.564 0.556 0.544 0.542
 [49] 0.534 0.504 0.500 0.492 0.474 0.472 0.458 0.442 0.436 0.430 0.428 0.426
 [61] 0.416 0.410 0.406 0.392 0.390 0.388 0.378 0.376 0.374 0.372 0.366 0.364
 [73] 0.362 0.360 0.356 0.354 0.352 0.348 0.342 0.336 0.334 0.330 0.326 0.324
 [85] 0.316 0.312 0.310 0.304 0.300 0.298 0.294 0.290 0.286 0.284 0.282 0.278
 [97] 0.276 0.274 0.268 0.266 0.264 0.262 0.260 0.258 0.256 0.254 0.252 0.250
[109] 0.248 0.246 0.244 0.242 0.236 0.232 0.230 0.228 0.224 0.222 0.216 0.214
[121] 0.212 0.208 0.206 0.204 0.202 0.200 0.198 0.196 0.192 0.190 0.188 0.186
[133] 0.182 0.178 0.176 0.172 0.170 0.168 0.162 0.160 0.158 0.156 0.154 0.152
[145] 0.150 0.148 0.146 0.144 0.142 0.140 0.138 0.136 0.134 0.132 0.130 0.128
[157] 0.126 0.124 0.122 0.120 0.118 0.116 0.114 0.112 0.110 0.108 0.106 0.104
[169] 0.102 0.100 0.098 0.096 0.094 0.092 0.090 0.088 0.086 0.084 0.082 0.080
[181] 0.078 0.076 0.074 0.072 0.070 0.068 0.066 0.064 0.062 0.060 0.058 0.056
[193] 0.054 0.052 0.050 0.048 0.046 0.044 0.042 0.040 0.038 0.036 0.034 0.032
[205] 0.030 0.028 0.026 0.024 0.022 0.020 0.018 0.016 0.014 0.012 0.010 0.008
[217] 0.006 0.004 0.002 0.000

$fpr
  [1] 0.000000000 0.002624672 0.003499563 0.003499563 0.003499563 0.003499563
  [7] 0.004374453 0.004374453 0.005249344 0.005249344 0.005249344 0.006124234
 [13] 0.006999125 0.006999125 0.007874016 0.007874016 0.007874016 0.007874016
 [19] 0.008748906 0.008748906 0.008748906 0.008748906 0.010498688 0.011373578
 [25] 0.012248469 0.013123360 0.013123360 0.013123360 0.013123360 0.013998250
 [31] 0.014873141 0.015748031 0.015748031 0.016622922 0.016622922 0.017497813
 [37] 0.019247594 0.020122485 0.021872266 0.023622047 0.024496938 0.024496938
 [43] 0.024496938 0.024496938 0.024496938 0.025371829 0.026246719 0.027121610
 [49] 0.027996500 0.028871391 0.029746282 0.029746282 0.031496063 0.032370954
 [55] 0.033245844 0.034120735 0.034995626 0.034995626 0.034995626 0.034995626
 [61] 0.034995626 0.035870516 0.035870516 0.036745407 0.041994751 0.042869641
 [67] 0.042869641 0.043744532 0.044619423 0.046369204 0.047244094 0.047244094
 [73] 0.048118985 0.048118985 0.048993876 0.050743657 0.050743657 0.053368329
 [79] 0.053368329 0.053368329 0.054243220 0.055118110 0.055118110 0.055993001
 [85] 0.056867892 0.056867892 0.057742782 0.059492563 0.060367454 0.061242345
 [91] 0.062117235 0.062992126 0.063867017 0.064741907 0.065616798 0.069116360
 [97] 0.069991251 0.071741032 0.076990376 0.079615048 0.080489939 0.080489939
[103] 0.080489939 0.081364829 0.084864392 0.085739283 0.093613298 0.093613298
[109] 0.097112861 0.097987752 0.100612423 0.102362205 0.103237095 0.104986877
[115] 0.104986877 0.105861767 0.107611549 0.110236220 0.111111111 0.111986002
[121] 0.112860892 0.112860892 0.113735783 0.114610674 0.116360455 0.117235346
[127] 0.117235346 0.118985127 0.119860017 0.121609799 0.124234471 0.125984252
[133] 0.126859143 0.127734033 0.128608924 0.132108486 0.133858268 0.134733158
[139] 0.139107612 0.140857393 0.143482065 0.145231846 0.146106737 0.146981627
[145] 0.152230971 0.154855643 0.156605424 0.158355206 0.161854768 0.164479440
[151] 0.167104112 0.167979003 0.170603675 0.171478565 0.175853018 0.180227472
[157] 0.181977253 0.186351706 0.187226597 0.189851269 0.195100612 0.198600175
[163] 0.199475066 0.200349956 0.202974628 0.206474191 0.209973753 0.211723535
[169] 0.216972878 0.219597550 0.220472441 0.224846894 0.225721785 0.230096238
[175] 0.237095363 0.237095363 0.239720035 0.246719160 0.249343832 0.251968504
[181] 0.257217848 0.260717410 0.261592301 0.265091864 0.269466317 0.276465442
[187] 0.281714786 0.286089239 0.287839020 0.292213473 0.294838145 0.300087489
[193] 0.304461942 0.308836395 0.314085739 0.320209974 0.323709536 0.330708661
[199] 0.334208224 0.337707787 0.342957130 0.346456693 0.352580927 0.356955381
[205] 0.363079615 0.374453193 0.384951881 0.393700787 0.403324584 0.417322835
[211] 0.420822397 0.427821522 0.441819773 0.452318460 0.465441820 0.489063867
[217] 0.523184602 0.559055118 0.619422572 1.000000000

$tpr
  [1] 0.0000000 0.1635220 0.1635220 0.1823899 0.1886792 0.2012579 0.2012579
  [8] 0.2075472 0.2075472 0.2138365 0.2201258 0.2201258 0.2264151 0.2327044
 [15] 0.2327044 0.2389937 0.2452830 0.2515723 0.2515723 0.2578616 0.2641509
 [22] 0.2704403 0.3018868 0.3018868 0.3018868 0.3018868 0.3081761 0.3144654
 [29] 0.3207547 0.3207547 0.3207547 0.3207547 0.3270440 0.3270440 0.3333333
 [36] 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0.3333333 0.3396226
 [43] 0.3459119 0.3522013 0.3584906 0.3584906 0.3647799 0.3647799 0.3647799
 [50] 0.3647799 0.3710692 0.3773585 0.3836478 0.3836478 0.3836478 0.3836478
 [57] 0.3836478 0.3899371 0.3962264 0.4025157 0.4150943 0.4150943 0.4213836
 [64] 0.4213836 0.4213836 0.4402516 0.4528302 0.4528302 0.4528302 0.4591195
 [71] 0.4591195 0.4654088 0.4654088 0.4716981 0.4779874 0.4779874 0.4842767
 [78] 0.4842767 0.5031447 0.5094340 0.5094340 0.5157233 0.5220126 0.5220126
 [85] 0.5220126 0.5283019 0.5471698 0.5471698 0.5471698 0.5471698 0.5471698
 [92] 0.5471698 0.5534591 0.5534591 0.5597484 0.5660377 0.5660377 0.5660377
 [99] 0.5660377 0.5660377 0.5660377 0.5723270 0.5786164 0.5786164 0.5849057
[106] 0.5849057 0.5911950 0.6037736 0.6037736 0.6037736 0.6037736 0.6100629
[113] 0.6100629 0.6226415 0.6289308 0.6289308 0.6289308 0.6477987 0.6477987
[120] 0.6477987 0.6477987 0.6540881 0.6540881 0.6603774 0.6603774 0.6603774
[127] 0.6666667 0.6666667 0.6666667 0.6666667 0.6666667 0.6666667 0.6729560
[134] 0.6729560 0.6729560 0.6729560 0.6729560 0.6792453 0.6918239 0.6918239
[141] 0.6981132 0.7044025 0.7106918 0.7106918 0.7169811 0.7169811 0.7169811
[148] 0.7169811 0.7169811 0.7169811 0.7169811 0.7169811 0.7169811 0.7232704
[155] 0.7232704 0.7232704 0.7232704 0.7232704 0.7232704 0.7232704 0.7358491
[162] 0.7358491 0.7358491 0.7358491 0.7484277 0.7484277 0.7484277 0.7547170
[169] 0.7547170 0.7610063 0.7610063 0.7610063 0.7610063 0.7610063 0.7610063
[176] 0.7672956 0.7735849 0.7735849 0.7861635 0.7924528 0.7924528 0.7924528
[183] 0.7987421 0.8050314 0.8113208 0.8176101 0.8238994 0.8238994 0.8238994
[190] 0.8238994 0.8301887 0.8364780 0.8364780 0.8364780 0.8427673 0.8427673
[197] 0.8427673 0.8490566 0.8490566 0.8553459 0.8553459 0.8553459 0.8553459
[204] 0.8553459 0.8553459 0.8553459 0.8616352 0.8742138 0.8805031 0.8867925
[211] 0.8930818 0.8930818 0.8930818 0.8930818 0.8993711 0.9119497 0.9119497
[218] 0.9119497 0.9245283 1.0000000

attr(,"class")
[1] "AUC" "roc"
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>