I have created a random forest object in R (using the randomForest
package) with ntree = N
. Now I would like to predict some new data on it using a subset of N
, that is using only n
trees for the prediction. Is this possible?
For the random forest object the forest is located at fit$forest
, but I don't know how to extract them (if possible).
Best Answer
Sounds like you want to set
predict.all = TRUE
. This will causepredict.randomForest
to return a list containing a vector of the aggregate predictions and a matrix of the individual tree predictions. You can then ensemble the individual trees at your leisure.Make sure you set
newdata = <something>
or this trigger fails for some reason.