I run random forest (using package randomForest) on the classic titanic data. Here are the code and results.

dt_rf <- randomForest(Survived ~ ., data = train, ntree = 500)

enter image description here

Wondering how shall I interpret the plot here. What does each line represent? Is it training, testing, and validation? If so, which one is which? And how does the randomForest function split the data?

  • $\begingroup$ Those are error rates which you will find in dt_rf$err.rate where the black line the OOB error while the red and green lines are for each of the two factors in your data. Your code's data = train suggests this is just on the training set. $\endgroup$
    – Henry
    Oct 26, 2021 at 8:13
  • $\begingroup$ @Henry Thanks. How can I tell which line (green or red) is for which level for my factor Y variable? $\endgroup$
    – ycenycute
    Oct 26, 2021 at 8:51
  • $\begingroup$ Look at head(dt_rf$err.rate) which will give you the values on the left hand side of the chart. The first factor will probably be the red line and the second green $\endgroup$
    – Henry
    Oct 26, 2021 at 8:56


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.