Similar questions have been asked on these two posts: random forest how to use the results and How to use random forest for regression after it is trained but I feel like the replies didn't give proper answers.

In python, I was able to use a random forest regression to predict a variable and the test data was quite positive. So now I'm interested in using it for later usages and well… how do I do that exactly?

Unlike a linear regression model where you just get the coefficients and you build a new model with these coefficients, how do you build a new model with the random forest? When I build this new code (that will be use by others), do I have to add the initial training data that I had in order to predict new incoming outputs? It seems a bit silly to do, no?

Thank you!

  • 1
    $\begingroup$ Why would you have to build a new linear regression model? As long as the model object is somewhere, you can call predict on it. Are you asking how to persist and distribute python objects? $\endgroup$ – Sycorax says Reinstate Monica Nov 28 '18 at 15:55
  • $\begingroup$ @Sycorax Yes exactly! I was looking on how this process should be done. So it's related to the language i'm using. I'll check that out. Thx $\endgroup$ – MorningGlory Nov 28 '18 at 17:17

Assuming you are using sklearn to train the Model, you could use pythons pickle module to save and load the model. See this link for an example.


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