liveBook · Manning

Association rule mining

As explained in Data Without Labels

An association rule is a relationship expressing the co-occurrence or implication of items or events.

A grocery retailer can use association rule mining to find products that appear together in transactions and consider those patterns when planning shelves, promotions, or prices. The technique searches many invoices for relationships that would be hard to spot by inspection; a discovered pattern is a candidate for a business decision, not a store-layout instruction by itself. section 4.2 section 4.8

A rule has the form P → Q: the antecedent P is a set of items, and the consequent Q is a separate set of items associated with it. Both sets draw from the items available, and they share no items. In transaction data, each invoice records which items were bought; a 1 or 0 can mark an item’s presence or absence. For example, {milk, bananas} → {eggs} expresses a purchasing pattern to investigate, not a guarantee that every qualifying shopper buys eggs. section 4.3 section 4.2

Table 4.1 Examples of invoices generated in a supermarket
Invoice number
Milk
Eggs
Bread
Cheese
1001
1
1
1
0
1002
0
0
0
1
1003
1
1
1
0
1004
0
1
0
1
1005
1
1
0
1

The five-invoice table makes a useful first check: invoice 1005 contains milk and eggs but no bread. Even an apparently clear basket pattern needs checking against every transaction. section 4.2

Judge whether a discovered rule is useful before acting on it:

  • Check support for how frequently the pattern occurs and confidence for how accurately the antecedent is followed by the consequent. section 4.11
  • Check lift as a dependence measure and consider conviction when assessing rule strength. Set thresholds for support, confidence, and lift to control rule generation. section 4.11
  • Review the result in its retail context: an obvious combination may add little insight, while hundreds of generated rules can be difficult to assess. section 4.9

Apriori generates frequent itemsets bottom-up but can struggle with large datasets. ECLAT uses depth-first search; F-P growth uses a frequent-pattern tree to avoid candidate generation. Python libraries including apyori, pyECLAT, and fpgrowth_py provide implementation routes without coding each algorithm from scratch. Sequence rule mining addresses events over time instead; SPADE is an algorithm for that related task. section 4.11 section 4.1

Before changing a store layout, remember what the invoices leave out. These rules treat different purchased quantities alike and ignore item cost and category differences such as perishability. Results also depend on the transactions analyzed: patterns from summer purchases need not hold in winter. Thresholds help manage rule volume, but business review and periodic refresh remain important. section 4.9 section 4.8

How Data Without Labels covers it

How deep it goes
Defines disjoint antecedents and consequents, introduces evaluation measures, and compares itemset algorithms without deriving metric formulas in the supplied excerpts.
Examples
Uses binary supermarket invoices, a beer-and-diapers anecdote, and grocery-store layout planning to illustrate patterns and decisions.
What it assumes
Assumes prior unsupervised-learning concepts and Python work while introducing itemsets, transactions, and rule notation explicitly.
What you can do after
Apply it via Python libraries to generate and assess purchasing rules before considering retail layout changes.
How it connects
Links market basket analysis and frequent itemsets to support, confidence, lift, conviction, and the related task of sequence rule mining.

Also explained in

Compare how 2 books explain association rule mining →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Data Without Labels. The section links point to the parts of the book it draws on.