Skip to main content

Association Rule Mining: Foundations

Source: Unit 4 §5

Given a set of transactions, association rule mining finds rules that predict the occurrence of an item based on the occurrences of other items.

The market-basket problem

TIDItems
1Bread, Milk
2Bread, Diaper, Beer, Eggs
3Milk, Diaper, Beer, Coke
4Bread, Milk, Diaper, Beer
5Bread, Milk, Diaper, Coke

Example rules read off this basket: {Diaper} → {Beer}, {Milk, Bread} → {Eggs, Coke}, {Beer, Bread} → {Milk}.

GotchaThe arrow is not a causal arrow

Implication here means CO-OCCURRENCE, not causality. {Diaper} → {Beer} says the two appear together often enough to clear the thresholds; it says nothing about one causing the other.

Key definitions

TermDefinition
Itemseta collection of one or more items, e.g. {Milk, Bread, Diaper}
k-itemsetan itemset with k items
Support count σfrequency: the number of transactions containing the itemset. σ({Milk,Bread,Diaper}) = 2
Support sfraction of transactions containing the itemset. s = 2/5 = 0.4
Frequent itemsetan itemset whose support ≥ minsup threshold
Association Rulean implication X → Y, where X and Y are itemsets

Rule evaluation metrics: support and confidence

For a rule X → Y:

Support(XY)=σ(XY)TConfidence(XY)=σ(XY)σ(X)\text{Support}(X \rightarrow Y) = \frac{\sigma(X \cup Y)}{|T|} \qquad \text{Confidence}(X \rightarrow Y) = \frac{\sigma(X \cup Y)}{\sigma(X)}

Support is the fraction of transactions containing both X and Y. Confidence is how often Y appears among the transactions that already contain X.

StepsWorked example: `{Milk, Diaper} → {Beer}`
  1. Support. σ(Milk, Diaper, Beer)=2\sigma(\text{Milk, Diaper, Beer}) = 2 (transactions 3 and 4), so s=2/5=0.4s = 2/5 = \mathbf{0.4}.
  2. Confidence. σ(Milk, Diaper)=3\sigma(\text{Milk, Diaper}) = 3 (transactions 3, 4 and 5), so c=2/3=0.67c = 2/3 = \mathbf{0.67}.
FactsLift, the third metric that usually rides along

Confidence alone rewards a rule whose right-hand side is simply common. Lift divides it out: Lift(XY)=Confidence(XY)Support(Y)\text{Lift}(X \rightarrow Y) = \frac{\text{Confidence}(X \rightarrow Y)}{\text{Support}(Y)}. For {Milk, Diaper} → {Beer}, Beer has support 3/5=0.63/5 = 0.6, so lift =0.67/0.6=1.11= 0.67 / 0.6 = 1.11: barely above 1, meaning the association is only slightly stronger than chance. Lift >1> 1 is positive association, =1= 1 is independence, <1< 1 is negative association.

The mining task, and why brute force fails

Goal: find all rules with support ≥ minsup AND confidence ≥ minconf.

  • Brute force: list every rule, compute support and confidence for each, and prune the ones below the thresholds. This is computationally prohibitive.
  • Key observation: rules from the same itemset - for example all the binary partitions of {Milk, Diaper, Beer} - have identical support but different confidence. So support and confidence can be decoupled and handled in separate phases.

The two-step approach

TransactiondatabaseN transactions1. FREQUENT ITEMSETGENERATIONkeep every itemset withsupport ≥ minsupthe expensive partfrequent itemsets2. RULEGENERATIONeach rule = one binarypartition of a frequent itemsetconfidence ≥ minconfM = 2^d candidate itemsetsbrute force = O(N · M · w)rules from one itemset all sharea support, but not a confidence
Support and confidence are decoupled on purpose: step 1 pays the exponential cost once, step 2 is cheap partitioning of what survived.
StepsThe two phases
  1. Frequent itemset generation - generate all itemsets with support ≥ minsup. This is the computationally expensive step.
  2. Rule generation - generate high-confidence rules from each frequent itemset, where each rule is a binary partition of that itemset.
NumbersWhy step 1 is the expensive one

Given d items there are 2d2^d possible candidate itemsets (the itemset lattice), so brute-force support counting costs O(NMw)O(N \cdot M \cdot w) with M=2dM = 2^d, where N is the number of transactions and w the transaction width.