I want to do some classification of some dataset with random forest. When I run the same script twice, two totally different(almost 5%) result were given by the program. I want to know whether random forest always give the result that change a lot with the same parameters? How can I make it more stable?


The Random Forest algorithm involves a lot of randomization, as I assume you know (right?). So you will get somewhat different results each time you run it.

To obtain reproducible results, which is a good idea, initialize your random number generator with a fixed number. In R, you can do this with set.seed(1), or with whatever other seed you want.

Be sure to investigate the effects of changing this seed, i.e., how sensitive your results are to your specific random number stream.

  • $\begingroup$ I used to think that the random can be stabled when a lot of data were feed in to the algorithm, can this be done with a lot of data and proper parameters? $\endgroup$ – maple Jun 17 '15 at 3:35
  • $\begingroup$ It really depends on your very specific data and its relationship to the outcome variable. If two appreciably different models explain your data about equally well, then any randomization approach will frequently switch between the two models, and the end result may depend in an unstable way on which model was picked how often. $\endgroup$ – Stephan Kolassa Jun 17 '15 at 3:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.