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

  1. Count 1-itemsets and keep L1, the frequent ones.
  2. Join frequent k-itemsets to form candidates C(k+1).
  3. Remove candidates containing an infrequent k-subset.
  4. Scan the database to count the remaining candidates.
  5. Keep those meeting minsup as L(k+1).
  6. 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:

  1. collects the prefix paths ending at D into D’s conditional pattern base;
  2. builds a smaller conditional FP-tree;
  3. recursively mines that tree;
  4. 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

AspectAprioriFP-growth
Main ideaGenerate and prune candidatesCompress transactions and recurse
Database scansSeveral level-based scansBuild the tree, then mine conditional trees
StrengthClear pruning logic and easy traceAvoids large candidate sets
Main costCandidate explosion and repeated scansTree 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.