1. Learn
  2. /
  3. Courses
  4. /
  5. Market Basket Analysis in Python

Connected

Exercise

Generating association rules

As you saw, the function permutations from the module itertools can be used to quickly generate the set of all one-antecedent, one-consequent rules. You do not, of course, know which of these rules are useful. You simply know that each is a valid way to combine two items.

Let's practice generating and counting the set of all rules for a subset of the grocery dataset: coffee, tea, milk, and sugar.

Instructions

100 XP
  • Complete the import statement to import the permutations function.
  • Generate all association rules from the groceries list.
  • Print the set of rules.
  • Print the number of rules.