To get the prediction in the database see help("predict.randomForest"). This will allow you to score the existing data: you then export the scores to the database using "RODBC" or similar package. This is what most people mean when the say they want to get the model into the database.

If you really want the model out so you can execute the model in the database (on new data not previously known to R) then either

1. Use the "pmml" package wich does have support for "randomForest" and consult your database for how to execute PMML models (also see http://www.dmg.org/ for more on PMML), or

[1.b. If your database is not supporting PMML directly, consider something like Zementis ADAPA http://www.zementis.com/ or another similar product, or]

2. Upgrade (!) to PostgreSQL, install the PL/R extension (http://www.joeconway.com/plr/), and run R directly in your database as a stored procedure or trigger language. (Neat.)

Allan

Nallan Suresh wrote:
Hi - I am new to RandomForest and want to be able to predict for a set of 
values outside of R.  So for example, if I create the model in R and want to 
get the prediction for an observation in a database, is there a way I can get 
the algorithm for the trees and final prediction for this model printed out in 
R that I can directly implement in SQL?  Or is the only way to do this is to 
use a wrapper and call R through SQL and predict the value?

Thanks
Suresh

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to