ROC curve using prebability of predicted class

十年热恋 提交于 2019-12-11 08:18:11

问题


I need to draw ROC curve using the predicted probabilities for two class problem. The need is to use different cutoff in probabilities to generate the ROC curve.

I am predicting class probabilities using random forest

mydata<-read.table(file="out-all-gm-pr-hpcuts-wor-noAl.tr", header=TRUE, sep ="")
mydata$class <- as.factor(mydata$class)
mydata.rf<-randomForest(class ~ ., data=mydata,  importance = TRUE, mtry = 3, ntree = 100, proximity = TRUE )

Prediction on test data using above forest

mytestdata<-read.table(file="gmsim-craboff.tes",header=TRUE)
testpred<-predict(mydata.rf,mytestdata,type='prob')

I now have a data file now with true class label and predicted probabilities for test data. I need to generate ROC curve using different cutoff (say 0.1, 0.3, 0.5, 0.7, 0.9) in probabilities. How to go about it?


回答1:


I would do the following:

library(pROC)
roc(mytestdata$class, testpred, plot = TRUE)


来源:https://stackoverflow.com/questions/14807310/roc-curve-using-prebability-of-predicted-class

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!