I have trained a predictive model based on random forest algorithm, but it took two days to train the model and the results were quite good according to test dataset.

The problem i am facing right now is that, every time i shut down my computer, if i need to make predictions based on new data, i have to run the model first, which made it very ineffective to make the predictions, so the more generalized question is the deployment of the model based on R. Is there any way that i could reuse the model without training the model first?


You should be able to save the model in binary form using the R "save" function (try typing ?save). Assuming that your model has the name "model" in your R code, it would be something like this:

save(model, file="model.RData")

This saves your model to a file called "model.RData". Then you should be able to load it next time using the R "load" function:


After this, the model should be in back in memory.


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.