FP-Growth & Kinds of Association Rules
Mining frequent patterns without candidate generation (FP-tree + conditional pattern bases), multilevel and multidimensional rules, and constraint-based mining.
▶Lecture videos
Click any timestamp — here or inside the notes — to jump the video to that moment. Your position is remembered.
FP-Tree Approach
The three steps of the FP-tree approach, with a worked example (beans, carrot, banana, mango…).
00:02FP-tree: no candidate generation, only two DB scans00:37Step 1 – scan once, find frequent 1-itemsets01:04Step 2 – remove infrequent items, sort each transaction by descending support01:42Step 3 – second scan builds a tree path per transaction02:21Worked example: 9 transactions, min support 304:28Building the tree transaction by transaction05:06Final tree: beans 8, carrot 7, banana 6, mango 5 …1Why not just use Apriori?
Apriori's candidate generate-and-test shrinks the candidate sets a lot, but it still has two non-trivial costs:
1. Huge candidate sets
With 10⁴ frequent 1-itemsets, Apriori must generate more than 10⁷ candidate 2-itemsets. That's 10⁴ × (10⁴ − 1)/2 ≈ 5 × 10⁷.
2. Repeated database scans
It scans the database again at every level and checks many candidates by pattern matching. Going over every transaction to count support is costly.
No candidate generation, and only two database scans 00:02. The video stresses that this is why computation time drops.
2FP-growth: the idea
Frequent-pattern growth (FP-growth) uses a divide-and-conquer strategy:
- Compress the database of frequent items into a frequent-pattern tree (FP-tree). The tree keeps the itemset association information.
- Divide the compressed database into conditional databases (a kind of projected database), each linked to one frequent item or "pattern fragment".
- Mine each conditional database separately.
The three steps of building the tree 00:37
How a transaction is inserted:
- Create a root labelled null.
- Process the items of each transaction in L order (descending support).
- If the transaction shares a prefix with an existing path, increment the count of each node along the shared prefix by 1.
- Create new nodes only for the items after the shared prefix.
- Keep an item header table: each item points to its occurrences in the tree through a chain of node-links.
The problem of mining the database becomes the problem of mining the FP-tree.
3Worked example (min_sup = 3)
| TID | Items bought | Ordered frequent items |
|---|---|---|
| 100 | f, a, c, d, g, i, m, p | f, c, a, m, p |
| 200 | a, b, c, f, l, m, o | f, c, a, b, m |
| 300 | b, f, h, j, o | f, b |
| 400 | b, c, k, s, p | c, b, p |
| 500 | a, f, c, e, l, p, m, n | f, c, a, m, p |
Supports after scan 1: f:4, c:4, a:3, b:3, m:3, p:3. Everything else (d, g, i, l, o, h, j, k, s, e, n) is below 3 and is dropped.
L order: f, c, a, b, m, p
Building the tree:
- T100 creates the path f:1 → c:1 → a:1 → m:1 → p:1.
- T200 shares the prefix f-c-a, so those become f:2, c:2, a:2, and a new branch b:1 → m:1 is added under a.
- After all five transactions, the FP-tree is:
null
/ \
f:4 c:1
/ \ \
c:3 b:1 b:1
| \
a:3 p:1
/ \
m:2 b:1
| \
p:2 m:1
4Mining the FP-tree
For each frequent item, starting from the least frequent (bottom of L) as the suffix:
- Build its conditional pattern base: the set of prefix paths in the tree that end just before the suffix, each with the suffix's count.
- Build the conditional FP-tree from that base, keeping only items whose total count ≥ min_sup.
- Mine it recursively. Patterns grow by concatenating the suffix with the patterns found in the conditional tree.
| Item | Conditional pattern base | Conditional FP-tree | Frequent patterns generated |
|---|---|---|---|
| p | {f,c,a,m : 2}, | ⟨c:3⟩ | {c,p : 3} |
| m | {f,c,a : 2}, | ⟨f:3, c:3, a:3⟩ | {f,m}, {c,m}, {a,m}, {f,c,m}, {f,a,m}, {c,a,m}, {f,c,a,m} : 3 |
| b | {f,c,a : 1}, {f : 1}, {c : 1} | ∅ (no item reaches 3) | — |
| a | {f,c : 3} | ⟨f:3, c:3⟩ | {f,a}, {c,a}, {f,c,a} : 3 |
| c | {f : 3} | ⟨f:3⟩ | {f,c} : 3 |
| f | ∅ | — | — |
p sits at the end of two paths: f-c-a-m-p (count 2) and c-b-p (count 1). The prefixes are {f,c,a,m}:2 and {c,b}:1. Totals: c = 2 + 1 = 3 ✓, while f, a, m = 2 and b = 1 ✗. So the conditional tree is just ⟨c:3⟩ and the pattern is {c, p}: 3.
- FP-growth turns finding long patterns into recursively finding short ones and concatenating the suffix.
- Using the least frequent items as suffixes gives good selectivity.
- It's efficient and scalable for both long and short patterns, and about an order of magnitude faster than Apriori.
- If the tree doesn't fit in memory, partition the DB into projected databases and build an FP-tree for each, recursively if needed.
FP-tree questions ask you to:
- Find the supports and drop infrequent items.
- Re-order each transaction.
- Draw the tree with counts.
- Make the conditional pattern base / conditional FP-tree / frequent patterns table.
Practise with the builder above. Change min_sup or paste the lecture's fruit/vegetable dataset.
5Multilevel association rules
- At low (primitive) levels, data is sparse, so strong associations are hard to find.
- Strong associations at high levels may just be common sense, but what is common sense to one user may be novel to another.
- So the system should mine at multiple levels of abstraction using concept hierarchies:
all
┌───────┬──────┼───────┬─────────────┐
computer software printer computer accessory
┌──┴──┐ … … …
laptop desktop
- Rules mined at multiple levels are multilevel association rules.
- They're mined under a support-confidence framework with a top-down strategy: count frequent itemsets at level 1, then go down level by level until no more frequent itemsets are found. Any algorithm (e.g. Apriori) works at each level.
| Approach | Thresholds | Example (computer 10%, laptop 6%, desktop 4%) |
|---|---|---|
| Uniform support | Same min_sup at every level | min_sup 5%: computer ✓, laptop ✓, desktop ✗ |
| Reduced support | Smaller min_sup at deeper levels | Level 1 = 5%, level 2 = 3%: computer ✓, laptop ✓, desktop ✓ |
Uniform support is simple, but if it's too high you miss meaningful low-level associations, and if it's too low you get too many uninteresting high-level ones. Reduced support fixes this by being more lenient at the specific levels.
6Multidimensional association rules
Each distinct predicate in a rule is a dimension.
| Type | Predicates | Example |
|---|---|---|
| Single-dimensional (intradimensional) | One predicate, repeated | buys(X, "digital camera") ⇒ buys(X, "HP printer") |
| Interdimensional | Two or more, no repeats | age(X, "20…29") ∧ occupation(X, "student") ⇒ buys(X, "laptop") |
| Hybrid-dimensional | Two or more, with a repeated predicate | age(X, "20…29") ∧ buys(X, "laptop") ⇒ buys(X, "HP printer") |
Count the distinct predicate names. One → single-dimensional. More than one with no repeats → interdimensional. More than one with a repeat → hybrid.
7Constraint-based association mining
- Mining can produce thousands of rules, most uninteresting.
- Users often know the "direction" and "form" of what they want, so they specify constraints to confine the search space. This is constraint-based mining.
| Constraint | Specifies | Example |
|---|---|---|
| Knowledge type | Type of knowledge | Association or correlation |
| Data | Task-relevant data | Sales in Colombo, 2025 |
| Dimension/level | Which dimensions or hierarchy levels | Use item at "brand" level, plus age |
| Interestingness | Thresholds on statistical measures | support ≥ 5%, confidence ≥ 70%, correlation |
| Rule | Form of rules: metarules (templates), max/min predicates on each side, relationships among attributes or aggregates | P(X, Y) ∧ Q(X, W) ⇒ buys(X, "laptop") |
8Quick revision sheet
| Concept | Remember it as |
|---|---|
| Apriori costs | Huge candidate sets (10⁴ items → 10⁷ pairs) + repeated DB scans |
| FP-growth | Divide & conquer, no candidates, 2 scans, ~10× faster |
| Tree build | Sort items by descending support, share prefixes (increment counts), header table + node-links |
| Mining | Least frequent suffix → conditional pattern base → conditional FP-tree → recurse & concatenate |
| Classic result | p→{c,p}:3 · m→{f,c,a,m}:3 · b→none · a→{f,c,a}:3 · c→{f,c}:3 |
| Too big for memory | Projected databases |
| Multilevel | Concept hierarchies, top-down; uniform vs reduced support |
| Multidimensional | Single (1 predicate repeated) · Inter (no repeats) · Hybrid (repeats) |
| Constraints | Knowledge type · Data · Dimension/level · Interestingness · Rule (metarules) |
?Self-check quiz
11 questions on this week. Answer them all, then press Check my answers. Your best and latest scores are saved and shown on the subject page.