[R] Dump decision trees of randomForest object

Christian Sturz linuxkaffee at gmx.net
Thu Oct 9 22:30:26 CEST 2008

I've tried the getTree() function and printed a decision tree with print().
However, it seems to me that it's hard to parse this representation and
translate it into equivalent if-then-else C constructs. Are there no other
ways to dump the trees into a more hierarchical form?

What do you exactly mean with the prediction in the source package?

Maybe what I wanted to ask goes in the same direction: let's say I've learned
a random forest model from a learning set. Now I would like to use it in the
future as classifier to predict new examples. How can this be done? Can I save
a learned model and than invoke R with new examples and applied them to
the saved model without again training the random forest from scratch? If so,
please give me some hints how to do that.


-------- Original-Nachricht --------
> Datum: Thu, 9 Oct 2008 14:38:44 -0400
> Von: "Liaw, Andy" <andy_liaw at merck.com>
> An: "Christian Sturz" <linuxkaffee at gmx.net>, r-help at r-project.org
> Betreff: RE: [R] Dump decision trees of randomForest object

> See the getTree() function in the package.  Also, the source package
> contains C code that does the prediction that you may be able to work
> from.
> Andy 
> From: Christian Sturz
> > 
> > Hi,
> > 
> > I'm using the package randomForest to generate a classifier 
> > for the exemplary
> > iris data set:
> > 
> > data(iris)
> > iris.rf<-randomForest(Species~.,iris)
> > 
> > Is it possible to print all decision trees in the generated forest?
> > If so, can the trees be also written to disk?
> > 
> > What I actually need is to translate the decision trees in a 
> > random forest
> > into equivalent C++ if-then-else constructs to integrate them in a C++
> > project. Have this been done in the past and are there already any
> > implemented approaches/parser for that?
> > 
> > Cheers,
> > Chris
> > --
> > 
> > ______________________________________________
> > R-help at 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.
> > 
> Notice:  This e-mail message, together with any attach...{{dropped:15}}

More information about the R-help mailing list