Lecture: Lecture 09 - Association Rules
Why algorithms are needed
With d possible items, there can be up to 2^d itemsets. Trying every itemset and scanning every transaction quickly becomes impractical. Frequent-itemset algorithms reduce the search.
Apriori principle
If an itemset is frequent, all of its subsets must be frequent. Equivalently, if a subset is infrequent, every larger set containing that subset can be pruned.
Suppose {B,E} has support below minsup. Then {A,B,E} cannot be frequent because every transaction containing A, B and E also contains B and E.
Apriori steps
- Count 1-itemsets and keep L1, the frequent ones.
- Join frequent k-itemsets to form candidates C(k+1).
- Remove candidates containing an infrequent k-subset.
- Scan the database to count the remaining candidates.
- Keep those meeting minsup as L(k+1).
- Stop when no frequent candidates remain.
In the source’s ten-row example, {B,E} has support 1 while the threshold is greater than 1. The algorithm therefore removes {A,B,E} before counting it. Later, {A,B,C,D} is counted and discarded because its support is only 1.
Apriori tradeoffs
Apriori is easy to trace and its pruning rule is powerful, but it may generate many candidates and scan the database repeatedly. Lowering minsup, increasing the number of items, enlarging the database or increasing transaction width can all increase the cost.
FP-growth
FP-growth first counts items, removes infrequent items and orders each transaction by decreasing support. It inserts the ordered transactions into an FP-tree, sharing common prefixes. A header table and item pointers connect occurrences.
To mine an item such as D, FP-growth:
- collects the prefix paths ending at D into D’s conditional pattern base;
- builds a smaller conditional FP-tree;
- recursively mines that tree;
- combines the results with D.
This is a divide-and-conquer search. It avoids the broad candidate-generation stage of Apriori and is particularly useful when transactions share prefixes. Compression is less effective when the data is sparse and transactions have little overlap.
Comparison
| Aspect | Apriori | FP-growth |
|---|---|---|
| Main idea | Generate and prune candidates | Compress transactions and recurse |
| Database scans | Several level-based scans | Build the tree, then mine conditional trees |
| Strength | Clear pruning logic and easy trace | Avoids large candidate sets |
| Main cost | Candidate explosion and repeated scans | Tree construction and memory |
Common confusion
Apriori does not claim that every frequent itemset should be reported as a rule. Frequent-itemset generation comes first; rule generation then evaluates possible splits using confidence and other constraints.
Retrieval questions
Why can {A,B,E} be pruned when {B,E} is infrequent? Any transaction containing the larger set must contain the infrequent subset, so the larger set cannot have higher support.
What does a shared FP-tree prefix represent? Multiple transactions sharing an ordered sequence of frequent items, with counts recording how many transactions use that path.
Why can FP-growth be less helpful for sparse data? Few transactions share prefixes, so the tree compresses little.
Source
Elena Baralis and Silvia Chiusano, Association Rules Fundamentals, PDF pages 13-73. The algorithm traces and tradeoffs are paraphrased from the lecture.