In the previous log, I briefly introduced the calculation of the RECALL,PRECISION,TPR,FPR and so on when using R for the logistic regression, but if the ROC curve is plotted in this way (for the concept of ROC and AUC, there are many introductions online, For example: http://beader.me/2013/12/15/auc-roc/) is too troublesome to manually adjust the classification threshold. In fact, R also provides the most basic ROC Curve Drawing Toolkit (package), combined with this log, I also introduce the installation and learning methods of the R package:
Here: http://www.r-project.org/Page Left click:
Download, Packages
CRAN
You can see the first need to select Cran mirror site, for example, we choose Beijing Jiaotong University: http://mirror.bjtu.edu.cn/cran/through a few links, you can browse this page: http://mirror.bjtu.edu.cn/cran/ web/packages/available_packages_by_name.html, the list is given in terms of the package name, along with a brief introduction to the package. We can see a description of proc here:
proc |
display and analyze ROC curves |
The installation can be downloaded as a compressed package, but it is often cumbersome to install it, so it is recommended to install it via the R console (you can see the name and the role of the packages first in this page):
Select "Package"--"installer package" in Rgui--Select the packages that need to be installed (also automatically installed if you need to install other dependent packages), if you choose the appropriate image (from my point of view, choose Lanzhou University's image, installation speed quickly), it will be ready to install. Finally give an example of stackoverflow on the other person, after installing the package can be run.
MyData <-read.csv ("Http://www.ats.ucla.edu/stat/data/binary.csv") Mylogit <-GLM (admit ~ GRE, data = MyData, Family = "Binomial") Summary (mylogit) prob=predict (mylogit,type=c ("response")) Mydata$prob=problibrary (PROC) G <- ROC (admit ~ prob, data = MyData) plot (g)
For other ways to use this package, API documentation can be found here:Http://www.inside-r.org/packages/cran/pROC/docs/auc. To sum up so much, I believe that the novice friends will be helpful.
When using R for classification, the ROC is plotted and the AUC is calculated