In a supermarket I selected $30$ products on which we want to run an analysis. I want to see which $12$ of them give me the widest coverage of clients (on a specific date, no time involved).
This means that I have $\displaystyle\frac{30!}{12!(30-12)!} = 86493225$ combinations of products
My dataframe of clients purchases:
| Client | Product |
|---|---|
| A | Banana |
| B | Apple |
| B | Banana |
| C | Water |
| ... |
codewise I could iterate to see the combination of highest client count, I am presenting the same problem as a coding issue here
but do you see a why I could calculate this as a formula, without having to iterate across all combinations?
please note that I do not want to find the combination of $12$ most common products, but the combination that will yield the most clients (possibly the same but not necessarily, as $2$ products not individually common may yield more clients if the $2$ groups don't overlap much).
any thoughts?
thank you