Random Forest - How to create every tree with only a certain amount of random features?

1 回表示 (過去 30 日間)
Laurynas Angelbeck
Laurynas Angelbeck 2021 年 4 月 9 日
回答済み: Prince Kumar 2021 年 11 月 23 日
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

回答 (1 件)

Prince Kumar
Prince Kumar 2021 年 11 月 23 日
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

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by