# Finding total number of combinations from list of buckets in each feature

I have 3 features age, income and rating.

In case of age I have 3 buckets.

for income I have 4 buckets.

and for rating I have 2 buckets.

If one could filter data where a person could select 1 or more than 1 bucket from each feature what would be the total number of combinations that can be selected?

E.g

Age = [less than 18, 18 < age <= 30, greater than 30]
Rating = [Low, High]

Combination_1 = [less than 18, Low]
Combination_2 = [18 < age <= 30, Low]
Combination_3 = [greater than 30, Low]
Combination_4 = [less than 18, High]
Combination_5 = [18 < age <= 30, High]
Combination_6 = [greater than 30, High]
Combination_7 = [less than 18, None]
Combination_8 = [18 < age <= 30, None]
Combination_9 = [greater than 30, None]
Combination_10 = [None, Low]
Combination_11 = [None, High]
Combination_12 = [None,None]


In this example there will be 12 combinations. What would be a generalized formula to achieve this? Here None represents nothing is filtered from the feature.

Edit: None here is not a feature but just a representation to tell it can be possible that nothing is selected.

Combination_1 = [less than 18, Low]
Combination_2 = [18 < age <= 30, Low]
Combination_3 = [greater than 30, Low]
Combination_4 = [less than 18, High]
Combination_5 = [18 < age <= 30, High]
Combination_6 = [greater than 30, High]
Combination_7 = [less than 18, None]
Combination_8 = [18 < age <= 30, None]
Combination_9 = [greater than 30, None]
Combination_10 = [None, Low]
Combination_11 = [None, High]
Combination_12 = [None,None]


As one could select more than 1 bucket from each feature following combinations are also possible.

Combination_13 = [[less than 18,18 < age <= 30], Low]
Combination_14 = [[less than 18,18 < age <= 30], high]
Combination_15 = [[less than 18,18 < age <= 30], None]

Combination_16 = [[less than 18,18 < age <= 30, greater than 30], Low]
Combination_17 = [[less than 18,18 < age <= 30, greater than 30], high]
Combination_18 = [[less than 18,18 < age <= 30, greater than 30], None]

Combination_19 = [less than 18, [High,Low]]
Combination_20 = [18 < age <= 30, [High,Low]]
Combination_21 = [greater than 30, [High,Low]]

Combination_22 = [[less than 18,18 < age <= 30], [High,Low]]
Combination_23 = [[less than 18,18 < age <= 30], [High,Low]]
Combination_24 = [[less than 18,18 < age <= 30], [High,Low]]

Combination_25 = [[less than 18,18 < age <= 30, greater than 30], [High,Low]]
Combination_26 = [[less than 18,18 < age <= 30, greater than 30], [High,Low]]
Combination_27 = [[less than 18,18 < age <= 30, greater than 30], [High,Low]]

• I request clarification re "... could select 1 or more than 1 bucket from each feature..." which suggests that at least 1 bucket from each feature is suggested. However, in your example, you showed Combination_12, which suggests that you are allowed to ignore both the Age and Rating features. It is as if you have added the None attribute to the group of age features and added the None attribute to the group of rating features. Before I can give a hint or an answer, I need clarification on this point. Oct 12, 2020 at 5:46
• You say you have two choices for rating but I see you are using "none" too. So you really have $3$ choices for rating. Also as an example, if the age is less than 18, what are the options for income? Think of any such dependencies. Oct 12, 2020 at 5:48
• @MathLover +1, re "...dependencies." That one got past me. Oct 12, 2020 at 5:50
• @user2661923 I just added to your note. I think the most imp clarification required is how he is choosing only some features and not all. Oct 12, 2020 at 5:54
• @user2661923 I've made an edit where I've added more combinations that are possible given the statement "... could select 1 or more than 1 bucket from each feature...". None in the combination represents nothing was selected form that feature Oct 12, 2020 at 6:07

Based on all clarifications in comments, here is how you can look at the number of combinations -

Each dropdown value in the feature can be independently selected - there are $$2$$ options - either it is selected or not selected = 2 ways.

So for Age feature $$= 2^3$$ combinations, as there are $$3$$ dropdown values. If none the values are selected, that is included in $$2^3$$ combinations.

For Income feature $$= 2^4$$ combinations.

For Rating feature $$= 2^2$$ combinations.

So total number of combinations $$= 2^3 \times 2^4 \times 2^2 = 2^9 = 512$$ combinations.

Please note this includes a case if none of the values from any of the features are selected (i.e. no feature is selected).

• if I use this formula on example mentioned in question. I get 32 combinations however there should be 27. $$2^5 - 5 = 27$$ Oct 12, 2020 at 7:26
• @Daniel Yes it will be 32. You may be missing some. Let me go through the example in your question to see which one's are you missing. Oct 12, 2020 at 7:29
• Only "18 < age <= 30, greater than 30", where are those combinations for example? I did not seem them. Oct 12, 2020 at 7:34
• There are
$$\binom{n}{0}+\binom{n}{1}+\dots+\binom{n}{n}\\=(1+1)^n\\=2^n$$ mutually exclusive-ways of selecting any number (including zero) of buckets
from $$n$$ buckets.

Since the $$m$$ features are independent (i.e., the choice of bucket(s) from each feature is regardless of the choice of bucket(s) from the other features) and each contains $$n$$ buckets, there are $$2^{n_1} \times 2^{n_2} \times \dots \times 2^{n_m}\\=2^{n_1+\dots+n_m}$$ combinations in total.

So for the case at hand (3, 4 & 2 buckets across the three features), there are $$2^{3+4+2}\\=512$$ combinations in total.

• Or, more simply, there are $$\binom{n_1+\dots+n_m}{0}+\binom{n_1+\dots+n_m}{1}+\dots+\binom{n_1+\dots+n_m}{n_1+\dots+n_m}\\=2^{n_1+\dots+n_m}$$ mutually-exclusive ways of selecting any number (including zero) of buckets from $$(n_1+\dots+n_m)$$ buckets.

• Even more straightforward is @user2661923 's framing in the comments: the $$(n_1+\dots+n_m)$$ buckets can each be independently categorised in $$2$$ ways — Pick or Reject — so $$2^{n_1+\dots+n_m}$$ combinations in total.