Data Mining �Association Analysis: APRIORI algorithm
Association Rule Mining
Market-Basket transactions
Example of Association Rules
{Diaper} → {Beer},�{Milk, Bread} → {Eggs,Coke},�{Beer, Bread} → {Milk},
Implication means co-occurrence, not causality!
Definition: Frequent Itemset
Definition: Association Rule
Example:
Association Rule Mining Task
⇒ Computationally prohibitive!
Mining Association Rules
Example of Rules:�
{Milk,Diaper} → {Beer} (s=0.4, c=0.67)�{Milk,Beer} → {Diaper} (s=0.4, c=1.0)
{Diaper,Beer} → {Milk} (s=0.4, c=0.67)
{Beer} → {Milk,Diaper} (s=0.4, c=0.67) �{Diaper} → {Milk,Beer} (s=0.4, c=0.5)
{Milk} → {Diaper,Beer} (s=0.4, c=0.5)
Observations:
Mining Association Rules
Frequent Itemset Generation
Given d items, there are 2d possible candidate itemsets
Frequent Itemset Generation
Computational Complexity
If d=6, R = 602 rules
Frequent Itemset Generation Strategies
Reducing Number of Candidates
Illustrating Apriori Principle
Found to be Infrequent
Pruned supersets
Illustrating Apriori Principle
Items (1-itemsets)
Pairs (2-itemsets)
(No need to generate�candidates involving Coke�or Eggs)
Triplets (3-itemsets)
Minimum Support = 3
If every subset is considered,
6C1 + 6C2 + 6C3 = 41
With support-based pruning,
6 + 6 + 1 = 13
Apriori Algorithm
Reducing Number of Comparisons
Generate Hash Tree
2 3 4
5 6 7
1 4 5
1 3 6
1 2 4
4 5 7
1 2 5
4 5 8
1 5 9
3 4 5
3 5 6
3 5 7
6 8 9
3 6 7
3 6 8
1,4,7
2,5,8
3,6,9
Hash function
Suppose you have 15 candidate itemsets of length 3:
{1 4 5}, {1 2 4}, {4 5 7}, {1 2 5}, {4 5 8}, {1 5 9}, {1 3 6}, {2 3 4}, {5 6 7}, {3 4 5}, {3 5 6}, {3 5 7}, {6 8 9}, {3 6 7}, {3 6 8}
You need:
Association Rule Discovery: Hash tree
1 5 9
1 4 5
1 3 6
3 4 5
3 6 7
3 6 8
3 5 6
3 5 7
6 8 9
2 3 4
5 6 7
1 2 4
4 5 7
1 2 5
4 5 8
1,4,7
2,5,8
3,6,9
Hash Function
Candidate Hash Tree
Hash on 1, 4 or 7
Association Rule Discovery: Hash tree
1 5 9
1 4 5
1 3 6
3 4 5
3 6 7
3 6 8
3 5 6
3 5 7
6 8 9
2 3 4
5 6 7
1 2 4
4 5 7
1 2 5
4 5 8
1,4,7
2,5,8
3,6,9
Hash Function
Candidate Hash Tree
Hash on 2, 5 or 8
Association Rule Discovery: Hash tree
1 5 9
1 4 5
1 3 6
3 4 5
3 6 7
3 6 8
3 5 6
3 5 7
6 8 9
2 3 4
5 6 7
1 2 4
4 5 7
1 2 5
4 5 8
1,4,7
2,5,8
3,6,9
Hash Function
Candidate Hash Tree
Hash on 3, 6 or 9
Subset Operation
Given a transaction t, what are the possible subsets of size 3?
Subset Operation Using Hash Tree
1 5 9
1 4 5
1 3 6
3 4 5
3 6 7
3 6 8
3 5 6
3 5 7
6 8 9
2 3 4
5 6 7
1 2 4
4 5 7
1 2 5
4 5 8
1 2 3 5 6
1 +
2 3 5 6
3 5 6
2 +
5 6
3 +
1,4,7
2,5,8
3,6,9
Hash Function
transaction
Subset Operation Using Hash Tree
1 5 9
1 4 5
1 3 6
3 4 5
3 6 7
3 6 8
3 5 6
3 5 7
6 8 9
2 3 4
5 6 7
1 2 4
4 5 7
1 2 5
4 5 8
1,4,7
2,5,8
3,6,9
Hash Function
1 2 3 5 6
3 5 6
1 2 +
5 6
1 3 +
6
1 5 +
3 5 6
2 +
5 6
3 +
1 +
2 3 5 6
transaction
Subset Operation Using Hash Tree
1 5 9
1 4 5
1 3 6
3 4 5
3 6 7
3 6 8
3 5 6
3 5 7
6 8 9
2 3 4
5 6 7
1 2 4
4 5 7
1 2 5
4 5 8
1,4,7
2,5,8
3,6,9
Hash Function
1 2 3 5 6
3 5 6
1 2 +
5 6
1 3 +
6
1 5 +
3 5 6
2 +
5 6
3 +
1 +
2 3 5 6
transaction
Match transaction against 11 out of 15 candidates
Factors Affecting Complexity
Compact Representation of Frequent Itemsets
Maximal Frequent Itemset
Border
Infrequent Itemsets
Maximal Itemsets
An itemset is maximal frequent if none of its immediate supersets is frequent
Closed Itemset
Maximal vs Closed Itemsets
Transaction Ids
Not supported by any transactions
Maximal vs Closed Frequent Itemsets
Minimum support = 2
# Closed = 9
# Maximal = 4
Closed and maximal
Closed but not maximal
Maximal vs Closed Itemsets
Alternative Methods for Frequent Itemset Generation
Alternative Methods for Frequent Itemset Generation
Alternative Methods for Frequent Itemset Generation
Alternative Methods for Frequent Itemset Generation