[R] Help with RandomForest

Liaw, Andy andy_liaw at merck.com
Mon May 17 15:35:01 CEST 2010


Steve,

It sounds to me like you want to use the model to predict data in other
maps.  If so, you should be using predict(), not getTree().  getTree()
shows the classification rules in _one_ of the trees in the forest
(default the first tree), which is rarely of interest if you've grown
hundreds of trees in the model, since the prediction is formed by
aggregating all the predictions from all the trees.

Best,
Andy 

> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of 
> Steve_Friedman at nps.gov
> Sent: Monday, May 17, 2010 9:21 AM
> To: r-help at r-project.org
> Subject: [R] Help with RandomForest
> 
> 
> I'm working with the randomForest package and have 
> successfully build a model.  I'd like to go one step further 
> however, and use the output from the model to construct a map 
> using the output.  My input data are spatial, and I have an 
> independent set of rasterize maps for each of the predictor 
> variables, to map the classification solution.
> 
> Using the getTree function:
> 
> > getTree(randomForest(veg.physical[,-1], veg.physical[,1], 
> ntree = 20, 
> > ),
> labelVar = TRUE)
> 
> returns a  "list" with dim(tree)  451 rows x 6 columns.
> 
> I assume that other folks using this package and publishing 
> maps have used this list to link the left and right 
> daughters, split variable, and the split point back to a map.
> 
> Here is a brief example( just the first 6 rows)  of that list:
>         left daughter right daughter split var        split point
> status prediction
> 1             2                     3           TN            
>     32.665
>       1       <NA>
> 2             4                     5           TN            
>     12.310
>        1       <NA>
> 3             6                     7           BD            
>     0.125
>       1       <NA>
> 4             8                     9     Total_Mg          4218.000
>  1       <NA>
> 5            10               11          LOI               92.475
> 1       <NA>
> 6            12               13    Total_Mg          831.000 
>           1
> <NA>
> 
> 
> This is where I'm searching for a procedure to accomplish 
> that.  If anyone has a procedure I would greatly appreciate 
> it if you would share that with me.
> 
> Thanks
> Steve
> 
> 
> Steve Friedman Ph. D.
> Spatial Statistical Analyst
> Everglades and Dry Tortugas National Park 950 N Krome Ave 
> (3rd Floor) Homestead, Florida 33034
> 
> Steve_Friedman at nps.gov
> Office (305) 224 - 4282
> Fax     (305) 224 - 4147
> 
> ______________________________________________
> 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 attachme...{{dropped:11}}



More information about the R-help mailing list