14.11 ROC Chart

Another measure of the quality of a model is the ROC curve and in particular the area under the ROC curve. This area can be calculated using ROCR::prediction() and ROCR::performance() from ROCR (Sing et al. 2026). These functions use the probability of a prediction rather than the prediction of a class.

In the following code block we obtain the predicted probabilities from the model, predicting over the te dataset. The result from calling stats::predict() is a matrix with columns corresponding to the possible class values recording the probability of each class for each observation. The second column is the one of interest (the probability that it will rain tomorrow or rain_tomorrow==yes). These probabilities are passed on to ROCR::prediction() to compare them with the actual target values. The result is then passed on to ROCR::performance() from which we obtain the base::attr()ibute y.values and then magrittr::extract2() the first value as the area under the curve.

References

Sing, Tobias, Oliver Sander, Niko Beerenwinkel, and Thomas Lengauer. 2026. ROCR: Visualizing the Performance of Scoring Classifiers. https://ipa-tys.github.io/ROCR/.


If you find this curated material useful then you can consider a donation to support it's ongoing availability and give you access to the PDF version of this book. The material has been scoped up by Generative AI without permission or any kind of recompense so do consider a donation if you can afford it. Unlike Generative AI your access to this materials is freely given. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Togaware has a 30 year tradition of making popular open source software which includes sold privacy preserving productivity apps, rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0