After running a randomForest, I have an object RF that contains a bunch of info. If I highlite the objects name and hit CTRL + R, I get the following:
> RF
Call:
randomForest(x = iris[-5], iris[5], ntree = 50, sampsize = c(100), importance = TRUE, do.trace = F, forest = TRUE)
Type of random forest: regression
Number of trees: 50
No. of variables tried at each split: 2
Mean of squared residuals: 0.03852423
% Var explained: 13.13
My question is how would I just print the last line (% Var explained: 13.13)?
I know for some functions there is a call like hist$breaks that will give a specific part of the object. I can’t find anything similar for this object. Any suggestions?
The % variance explained is supposed to be analogous to an R^2 type value. If you look at
?randomForestyou’ll see that one of the values in the object is accessed via$rsq. Just multiply that by 100.