[R] Extracting the MSE and % Variance from RandomForest

Liaw, Andy andy_liaw at merck.com
Fri Apr 23 03:46:05 CEST 2004

Several ways:

1. Read ?randomForest, especially the `Value' section.
2. Look at str(myforest.rf).
3. Look at print.randomForest.

If the forest has 100 trees, then the mse and rsq are vectors with 100
elements each, the i-th element being the mse (or rsq) of the forest
consisting of the first i trees.  So the last element is the mse (or rsq) of
the whole forest.


> From: David L. Van Brunt, Ph.D.
> I'm almost embarrassed to ask... Almost!
> I've typed "names(myforest.rf)" to see that lots of 
> interesting info can be
> called out bit by bit...
> But I can't seem to figure out how to just grab one or two 
> the summary stats
> so I can save it out into a table alongside the prediction 
> for the new data.
> Specifically, though I see "rsq" for all the trees, and ditto 
> for "mse",
> (here's the embarrassing part) how do I just save the mse or 
> % Var for the
> whole forest? I really can't find it, not for lack of 
> looking. Just clearly
> not in the right place!
> Or do I need to calculate it somehow?
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! 
> http://www.R-project.org/posting-guide.html

More information about the R-help mailing list