我需要使用两类问题的预测概率绘制ROC曲线。需要在概率中使用不同的截止值来生成ROC曲线。
我使用随机森林预测班级概率
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 )
使用上面的森林预测测试数据
mytestdata<-read.table(file="gmsim-craboff.tes",header=TRUE)
testpred<-predict(mydata.rf,mytestdata,type='prob')
我现在有一个数据文件,现在具有真正的类标签和测试数据的预测概率。我需要在概率中使用不同的截止值(例如0.1
,0.3
,0.5
,0.7
,0.9
)生成ROC曲线。怎么去呢?
答案 0 :(得分:1)
我会做以下事情:
library(pROC)
roc(mytestdata$class, testpred, plot = TRUE)