[R] ROC curve for each fold in one plot

Elahe chalabi chalabi.elahe at yahoo.de
Mon Oct 16 14:25:34 CEST 2017


Hi all,

I have tried a 5 fold cross validation using caret package with random forest method on iris dataset as example. Then I need ROC curve for each fold:


  > set.seed(1)
  > train_control <- trainControl(method="cv", number=5,savePredictions = TRUE,classProbs = TRUE) 
  > output <- train(Species~., data=iris, trControl=train_control, method="rf")
  > library(pROC)  
  > selectedIndices <- output$pred$Resample == "Fold1"
  > plot.roc(output$pred$obs[selectedIndices],output$pred$setosa[selectedIndices])  > selectedIndices <- output$pred$Resample == "Fold2"  
  > plot.roc(output$pred$obs[selectedIndices],output$pred$setosa[selectedIndices])
  > selectedIndices <- output$pred$Resample == "Fold3"
  > plot.roc(output$pred$obs[selectedIndices],output$pred$setosa[selectedIndices])

and the same for Fold4 and Fold5,now how can I bring all the plots in one plot with labels for each fold?

Thanks for any help!
Elahe



More information about the R-help mailing list