Search code examples
javarrandom-forestalglib

How I can extract the RandomForest from R for use in production?


I have a successful randomforest model, and I want to integrate it in another software, I know that I can use some libraries (like fastRF in Java o ALGLIB's DecisionForest for other languages) but how I can use the "model" trained in R? I have to re-train it in the new language?

Another view is extract it somehow, but I dont't know how to do it...

Any help will be appreciated

Thanks in advance


Solution

  • Take a look at the pmml package which generate PMML for various models, RandomForest included. A basic example:

    #?randomForest
    library(randomForest)
    library(pmml)
    set.seed(131)
    ozone.rf <- randomForest(Ozone ~ ., data=airquality, mtry=3,importance=TRUE, na.action=na.omit)
    print(ozone.rf)
    ozone.rf.pmml <- pmml(ozone.rf)