ROC curve using prebability of predicted class

2019-07-27 12: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?

标签: r roc
1条回答
趁早两清
2楼-- · 2019-07-27 12:40

I would do the following:

library(pROC)
roc(mytestdata$class, testpred, plot = TRUE)
查看更多
登录 后发表回答