I'm trying to save a model generated by Random Forest and retrieve it for later use.
I'm using the following code for the model generation:
// .. some code .. //
engine.SetSymbol("_mydata", sourceset); // sourceset is the source data frame
String modelExpression = "randomForest(HealthFactor,data=_mydata,importance=TRUE,proximity=TRUE)";
GenericVector model = engine.Evaluate(modelExpression).AsList();
Now, I'd like to save the GenericVector model in any format that can be written to a text file so I can retrieve it for future prediction use.
The prediction code will look like this:
engine.SetSymbol("pset", predictionset); // predictionset is the data used to predict
String predictionExpression = "predict(mymodel, pset)";
// predict the results
DynamicVector predResults = engine.Evaluate(predictionExpression).AsVector();
I tried to force the GenericVector to byte, but the class (and its sub list classes) is not serializable.
Is there any way that I can save the model object and reuse it later? Thank for any help.