Based on: http://blog.revolutionanalytics.com/2016/08/roc-curves-in-two-lines-of-code.html
graphROC(modelPredictions, yValues)
modelPredictions | numeric predictions (not empty) |
---|---|
yValues | logical truth (not empty, same lenght as model predictions) |
line graph, point graph, and area under curve
See also https://github.com/WinVector/sigr
set.seed(34903490) x = rnorm(50) y = 0.5*x^2 + 2*x + rnorm(length(x)) frm = data.frame(x=x,yC=y>=as.numeric(quantile(y,probs=0.8))) WVPlots::graphROC(frm$x, frm$yC)#> $lineGraph #> FalsePositiveRate TruePositiveRate model #> 1 0.000 0.0 0.0000000 #> 2 0.000 0.1 1.9834442 #> 3 0.000 0.2 1.6874100 #> 4 0.000 0.3 1.3603187 #> 5 0.000 0.4 1.2908534 #> 6 0.025 0.4 1.0127769 #> 7 0.025 0.5 0.7639922 #> 8 0.050 0.5 0.7328199 #> 9 0.050 0.6 0.7284373 #> 10 0.050 0.7 0.6267063 #> 11 0.050 0.8 0.4816747 #> 12 0.075 0.8 0.4693716 #> 13 0.075 0.9 0.4143799 #> 33 0.575 0.9 -0.5967041 #> 34 0.575 1.0 -0.6464424 #> 52 1.000 1.0 1.0000000 #> #> $pointGraph #> FalsePositiveRate TruePositiveRate model #> 1 0.000 0.1 1.983444228 #> 2 0.000 0.2 1.687409961 #> 3 0.000 0.3 1.360318715 #> 4 0.000 0.4 1.290853427 #> 5 0.025 0.4 1.012776914 #> 6 0.025 0.5 0.763992198 #> 7 0.050 0.5 0.732819883 #> 8 0.050 0.6 0.728437303 #> 9 0.050 0.7 0.626706322 #> 10 0.050 0.8 0.481674679 #> 11 0.075 0.8 0.469371573 #> 12 0.075 0.9 0.414379907 #> 13 0.100 0.9 0.388966296 #> 14 0.125 0.9 0.322711745 #> 15 0.150 0.9 0.291897871 #> 16 0.175 0.9 0.243617009 #> 17 0.200 0.9 0.121084094 #> 18 0.225 0.9 0.080181707 #> 19 0.250 0.9 0.049574836 #> 20 0.275 0.9 0.004686402 #> 21 0.300 0.9 -0.015549969 #> 22 0.325 0.9 -0.033319466 #> 23 0.350 0.9 -0.047839856 #> 24 0.375 0.9 -0.137688548 #> 25 0.400 0.9 -0.169013827 #> 26 0.425 0.9 -0.237702135 #> 27 0.450 0.9 -0.246005968 #> 28 0.475 0.9 -0.329926323 #> 29 0.500 0.9 -0.348829025 #> 30 0.525 0.9 -0.374350637 #> 31 0.550 0.9 -0.443287224 #> 32 0.575 0.9 -0.596704088 #> 33 0.575 1.0 -0.646442449 #> 34 0.600 1.0 -0.676590876 #> 35 0.625 1.0 -0.763345785 #> 36 0.650 1.0 -0.802256679 #> 37 0.675 1.0 -0.883032976 #> 38 0.700 1.0 -0.908321256 #> 39 0.725 1.0 -0.951035040 #> 40 0.750 1.0 -0.984407237 #> 41 0.775 1.0 -1.104053854 #> 42 0.800 1.0 -1.153091156 #> 43 0.825 1.0 -1.185035416 #> 44 0.850 1.0 -1.197259325 #> 45 0.875 1.0 -1.220891584 #> 46 0.900 1.0 -1.510737697 #> 47 0.925 1.0 -1.523615915 #> 48 0.950 1.0 -1.564384313 #> 49 0.975 1.0 -1.669491250 #> 50 1.000 1.0 -2.619305847 #> #> $area #> [1] 0.9175 #>