Random Forest - How to create every tree with only a certain amount of random features?
2 views (last 30 days)
Show older comments
Hello everyone,
I have a dataset with 10 features and I want to use treebagger to create a random forest. But I need every tree build by only randomly selecting three random features first. and not all of them. For example the first decision tree would only contain feature (1,3,6), the second tree would use feature ( 4,9,10) and so on....
At first I thought I could use 'NumPredictorsToSample' but this argument only randomly selects features for every decision split and not the whole tree.
Maybe I could combine it with other arguments to achieve a similiar effect but I'm unsure.
Sorry if I'm missing some really obvious methode that would solve my problem.
So : How can I force treebagger to randomly select a certain(same) amount of features for each individual tree?
Thanks in advance
LA
0 Comments
Answers (1)
Prince Kumar
on 23 Nov 2021
Hi Laurynas Angelbeck,
In a random forest, variables are selected randomly for every split. However selecting a subset of predictors for the entire tree (via the subspace method) is not possible. So there aren't any workarounds when weak learners are trees.
Using the subspace method for other types of weak learners is possible. Here is an example using 'fitcensemble' with knn learners: Random Subspace Classification
0 Comments
See Also
Categories
Find more on Classification Ensembles in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!