# In a Random Forest model, are all possible variable combinations accounted for?

To preface this question, I am building a Random Forest model using the randomForest package in R. I am not sure if this question is dependent upon my program, or if it can be answered based on the inherent properties of the algorithm. I felt this question was more appropriate for "Cross Validated" versus "Overflow", please let me know if you think otherwise.

A Random Forest model creates many decision trees which contain a subset of variables and data. Is there any guarantee that every possible combination of variables are accounted for across all of the decision trees?

For example, I have 4 variables that I am feeding into the RF model. Three of those variables are binary (X1, X2, Y1, Y2, Z1, Z2). The other variable (of ordinal type) contains 8 unique values.(A1...A8). This leaves me with 56 possible variable combinations.

How can I guarantee that all possible unique combinations of variables are accounted for across trees? I understand that simply increasing the number of trees would increase the likelihood of this. I also realize that my example contains a relatively small number of variables, however consider a situation with many variables and unique combinations.

• No, there's no such garanty. The total number of combinations get very big, very fast. Commented Sep 28, 2017 at 15:01
• @Fernando I would suggest that you expand this comment to an answer, otherwise this question will stay unanswered Commented Sep 28, 2017 at 15:07

No, there's no such garanty. The total number of combinations gets very big, very fast.

The additional questions is: is that even necessary? Given that real data has noise and can present high correlation, forcing all combinations doesn't seem to help much.

If you know (by field experience) that all your variables are important, then maybe a deep neural net could work better.

• For my purposes, it would be necessary because I have determined my variables to all be relevant. As you suggest, I will take a look at deep neural networks Thank you for the information. I see how the number of combinations could be very, very large and how it would not be possible to account for all combinations in those situations. Commented Sep 28, 2017 at 15:48
• Deep nets may work well if you have a lot of variables with complex patterns and iterations. Commented Sep 28, 2017 at 17:33

A Random Forest model creates many decision trees which contain a subset of variables and data. Is there any guarantee that every possible combination of variables are accounted for across all of the decision trees?

No. Consider the extreme example where your forest consists of a single tree with depth one.

How can I guarantee that all possible unique combinations of variables are accounted for across trees? I understand that simply increasing the number of trees would increase the likelihood of this. I also realize that my example contains a relatively small number of variables, however consider a situation with many variables and unique combinations.

You can't. And, perhaps more importantly, you probably don't want that as well. Doing that would decrease the variance of the models.

Having said that, you could try bagged trees (without attribute bagging, i.e. random selection of features) instead of Random Forests ensuring that all combinations are visited at least once, but I'm not sure this model would perform any better than a full Random Forest.

• That makes sense. I was thinking that the process of actually "guaranteeing" each combination was covered would result in a loss in the true randomness of selecting variables/data. I will take a look at bagged trees, thank you for the information. Commented Sep 28, 2017 at 15:51