Howe to plot an average ROC on test data

by forever   Last Updated April 17, 2017 09:19 AM - source

I run the random forest algorithm in Caret package 50 times on different split of data.

my question is how to plot the average ROC for the test data?

MY code is like the below: prostate_df=read.csv(file=) for (k in 1:50) {

trainIndex <- createDataPartition(prostate_df$subtype, p = .8,list = FALSE,times = 1)

irisTrain <- prostate_df[ trainIndex,]

irisTest <- prostate_df[-trainIndex,]

control <- trainControl(method="cv", number=10,classProbs = TRUE,summaryFunction = twoClassSummary)

fit.rf <- train(subtype~., data=irisTrain, method="rf", trControl=control,metric="ROC")

rfClasses <- predict( fit.rf, newdata = irisTest,type="prob")

rfClasses1 <- predict( fit.rf, newdata = irisTest)

rfConfusion=confusionMatrix(data = rfClasses1, irisTest$subtype)

rf.ROC <- roc(predictor=rfClasses$X1,response=irisTest$subtype,levels=rev(levels(irisTest$subtype)))

}



Related Questions


How to define samples in caret package?

Updated April 29, 2015 23:08 PM


RandomForest - model not superior to NIR

Updated February 10, 2019 18:19 PM