0

This is probably an easy question but I have been stuck on it for ages. I have build a classification random forest model to predict the classifications of my test set and attached the outcome to my dataframe as follows.

RandomTree <- randomForest(as.factor(OutcomeVariable) ~ ., data=TrainSet, ntree=30 , 
importance=TRUE, samplesize=c(5195,5195))
Prediction<-predict(RandomTree, TestSet, type="response")
TestSet$Prediction<-Prediction

I want to try and create a ROC curve and calculate the AUC from this. I understand the classification predictions need to be converted to probabilities however I am unsure of how to do this. The reason for this is so I can compare the results of my random forest with a logistic regression I have also modeled. I was able to get a ROC curve from my logistic regression.

Any help would be much appreciated. Thanks

Fiona
  • 477
  • 1
  • 9
  • 18
  • The `caret` package might help you. It has functions designed specifically for that (plot ROC curves, compute AUC, compare models). – Aurèle Aug 10 '17 at 14:45
  • Possible duplicate of [ROC curve for classification from randomForest](https://stackoverflow.com/questions/12370670/roc-curve-for-classification-from-randomforest) – Calimo Aug 10 '17 at 16:44

0 Answers0