Remove or replace trees from a TreeBagger ensemble
显示 更早的评论
Hello,
There is this method TreeBagger.combine that can combine two independently trained TreeBagger classifiers.
The problem is that I have to combine two ensembles, but I want to replace randomly 25% of the trees from the first ensemble with trees from the second ensemble.
Three possible solutions to overcome my problem:
1. Method to remove specified trees from ensemble. Then I would just remove 25% of the ensemble with random indexes and combine with the second ensemble.
2. Method to construct new TreeBagger from a collection of trees. For example something like this:
TreeBagger=Construct(Tree1, Tree2, ...);
3. Method to replace trees in TreeBagger ensemble. For example I tried to do this, like in a structure:
ensemble.Trees{i}=new_tree;
but that didn't work, because the property is private.
Please help me, because I had no progress with any of three...
采纳的回答
更多回答(1 个)
Artik Crazy
2012-3-10
2 个评论
Ilya
2012-3-10
Various properties of your PrunedEnsemble are now broken. For example, OOBIndices are the indices of observations that are out-of-bag for the grown trees. Tree 101 in OriginalEnsemble must use column 101 of OOBIndices. In PrunedEnsemble, this tree has index 1 and will use column 1 of OOBIndices instead. Because the tree list and OOBIndices no longer match, you cannot use oobPredict anymore. This is just one example; there are other broken properties.
If you must go down this road, I would recommend modifying CompactTreeBagger in a similar fashion. You should then execute COMPACT on a TreeBagger object before removing trees. The compact class is simpler, and there is less chance you will screw something up by these changes. Certainly, the PREDICT method will work fine, but I cannot vouch for everything else.
Artik Crazy
2012-3-10
类别
在 帮助中心 和 File Exchange 中查找有关 Classification Ensembles 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!