Solved – way to remove individual trees from a forest in the randomForest package in R

cartmax-marginrrandom forest

I am trying to implement the ideas in this paper: http://www.sciencedirect.com/science/article/pii/S0925231212003396.

This requires me to be able to remove individual trees from the forest and reclassify my training data for each removal. I've been using the randomForest package in R and had a comb through the manual but couldn't find any way of running the forest with a subset of trees, or even with an individual tree. There is a getTree function but that only gives a matrix of the node structure of the tree.

Is there any way to do this, either in randomForest (preferably) or via another random forest implementation (e.g. scikit-learn)?

Best Answer

One idea is, instead of creating one forest with N trees, create N "forests" of 1 tree each by calling randomForest() N times. Then you could manipulate them as you wish.