## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

# Time for action – ROC construction

A simple dataset is considered and the ROC construction is explained in a very simple step-by-step approach:

1. Suppose that the predicted probabilities of n = 10 observations are 0.32, 0.62, 0.19, 0.75, 0.18, 0.18, 0.95, 0.79, 0.24, 0.59. Create a vector of it as follows:
`pred_prob<-c(0.32, 0.62, 0.19, 0.75, 0.18, 0.18, 0.95, 0.79, 0.24, 0.59)`
2. Sort the predicted probabilities in a decreasing order:
```> (pred_prob=sort(pred_prob,decreasing=TRUE))
[1] 0.95 0.79 0.75 0.62 0.59 0.32 0.24 0.19 0.18 0.18```
3. Normalize the predicted probabilities in the preceding step to the unit interval:
`> pred_prob<-(pred_prob-min(pred_prob))/(max(pred_prob)-min(pred_prob )) > pred_prob [1] 1.00000 0.79221 0.74026 0.57143 0.53247 0.18182 0.07792 ...`

## With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required