O'Reilly logo

R Data Analysis Cookbook - Second Edition by Kuntal Ganguly

Stay ahead with the world's most comprehensive technology and business learning platform.

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

Start Free Trial

No credit card required

How it works...

Step 1 loads the package and step 2 reads in the data file.

Step 3 creates a prediction object based on the probabilities and class labels passed in as arguments. In the current examples, our class labels are 0 and 1, and by default, 0 becomes the failure class and 1 becomes the success class. We will see in the There's more... section of this recipe how to handle the case of arbitrary class labels.

Step 4 creates a performance object based on the data from the prediction object. We indicate that we want the true positive rate and false positive rate.

Step 5 plots the performance object. The plot function does not plot the diagonal line indicating the ROC threshold, and we add a second line of code to get that.

We generally ...

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

Start Free Trial

No credit card required