Professional Documents
Culture Documents
Apriori
Lecture 5
Damanhour University
Faculty of Computers & Information Sciences
Department of Information Systems
2023 - 2024
Outline
The Basics
• Market Basket Analysis
• Frequent Item sets
• Association Rules
2
The Basics: What Is Frequent Pattern Analysis?
3
The Basics
21
The Basics
5
The Basics
6
The Basics : Frequent Itemsets
Itemset X = {x1, …, xk} ex: X={A, B, C, D, E, F}
Find all the rules X Y with minimum support and confidence
support, s, probability that a transaction contains X Y
confidence, c, conditional probability that a transaction having X also
contains Y
7
The Basics : Frequent Itemsets
Itemset X = {x1, …, xk} ex: X={A, B, C, D, E, F}
Find all the rules X Y with minimum support and confidence
support, s, probability that a transaction contains X Y
confidence, c, conditional probability that a transaction having X also
contains Y
8
The Basics : Association Rules
Ex: Let supmin = 50%, confmin = 50% Transaction-id Items bought
Freq. Pat.: {A:3, B:3, D:4, E:3, AD:3} 10 A, B, D
Association rules: 20 A, C, D
A D (60%, 100%) 30 A, D, E
D A (60%, 75%) 40 B, E, F
50 B, C, D, E, F
9
The Basics : Association Rules
10
Outline
The Basics
• Market Basket Analysis
• Frequent Item sets
• Association Rules
11
Mining Frequent Itemsets: Apriori
Goes as follows:
Find frequent 1-itemsets L1
Use L1 to find frequent 2-itemsets L2
… until no more frequent k-itemsets can be found
12
Mining Frequent Itemsets: Apriori
Itemset Support
count Itemset
Not all subsets are frequent
{I1, I2, I3} 2
{I1, I2, I3, I5} Prune
{I1, I2, I5} 2
C4 = Terminate
17
Mining Frequent Itemsets: Apriori
18
Apriori
Algorithm
Generate Ck using Lk-1 to find Lk
Join
Prune
19 11/6/2023
Mining Frequent Itemsets:
Generating Association Rules from Frequent Itemsets
20
Mining Frequent Itemsets:
Generating Association Rules from Frequent Itemsets
Nonempty subsets Association Rules Confidence
Itemset Support
count
{I1, I2} {I1, I2} I5 2/4 = 50%
{I1, I2, I3} 2
{I1, I2, I5} 2 {I1, I5} {I1, I5} I2 2/2 = 100%
22 11/6/2023
Mining Frequent Itemsets:
FP-Growth
FP-tree
L1 - Reordered null { }
Itemset Support Node
count Link
{I2} 7
{I1} 6
{I3} 6
{I4} 2
{I5} 2
24
Mining Frequent Itemsets:
FP-Growth – FP-tree Construction
FP-tree null { }
25
Mining Frequent Itemsets:
FP-Growth – FP-tree Construction
FP-tree null { }
L1 - Reordered
Itemset Support Node
I2:1 T200 TID List of items
count Link T100 I1, I2, I5
{I2} 7 T200 I2, I4
26
Mining Frequent Itemsets:
FP-Growth – FP-tree Construction
FP-tree
null { }
L1 - Reordered
Itemset Support Node
I2:2 T200
count Link TID List of items
27
Mining Frequent Itemsets:
FP-Growth – FP-tree Construction
FP-tree null { }
L1 - Reordered
Itemset Support Node
I2:2
count Link TID List of items
28
Mining Frequent Itemsets:
FP-Growth – FP-tree Construction
FP-tree
null { }
L1 - Reordered
Itemset Support Node
I2:3
count TID List of items
Link
T100 I1, I2, I5
{I2} 7 T300
T200 I2, I4
{I1} 6 I1:1 I3:1 I4:1
T300 I2, I3
{I3} 6 T400 I1, I2, I4
{I4} 2 I5:1
T500 I1, I3
29
Mining Frequent Itemsets:
FP-Growth – FP-tree Construction
FP-tree
null { }
L1 - Reordered
Itemset Support Node
I2:7 I1:2
count Link
{I2} 7
{I1} 6 I1:4 I3:2 I4:1 I3:2
{I3} 6
{I4} 2 I5:1 I3:2 I4:1
{I5} 2
For Tree
I5:1
Traversal
30
Mining Frequent Itemsets:
FP-Growth – FP-tree Construction
{I2} 7
I1:4 I3:2 I4:1 I3:2
{I1} 6
{I3} 6
{I4} 2 I5:1 I3:2 I4:1
{I5} 2
I5:1
31
Mining Frequent Itemsets:
FP-Growth – Conditional FP-tree Construction
For I5 FP-tree
L1 - Reordered null { }
Itemset Support Node
count Link
{I2} 7
TID List of items
{I1} 6
T100 I1, I2, I5
{I3} 6
T200 I2, I4
{I4} 2 T300 I2, I3
{I5} 2 T400 I1, I2, I4
{I2} 7
TID List of items
{I1} 6 I1:1
T100 I1, I2, I5
{I3} 6
T200 I2, I4
{I4} 2 T300 I2, I3
{I5} 2 T400 I1, I2, I4
L1 - Reordered
Itemset Support Node I2:2
count Link
{I2} 7
TID List of items
{I1} 6 I1:2
T100 I1, I2, I5
{I3} 6
T200 I2, I4
{I4} 2 T300 I2, I3
I3:1
{I5} 2 Eliminate transactions T400 I1, I2, I4
not including I5 T500 I1, I3
T600 I2, I3
For I4 FP-tree
null { }
L1 - Reordered
Itemset Support Node I2:2
count Link
{I2} 7
TID List of items
{I1} 6 I1:1
T100 I1, I2, I5
{I3} 6
T200 I2, I4
{I4} 2 T300 I2, I3
{I5} 2 Eliminate transactions T400 I1, I2, I4
not including I4 T500 I1, I3
T600 I2, I3
Eliminate I4 T700 I1, I3
T800 I1, I2, I3, I5
T900 I1,
35I2, I3
11/6/2023
Mining Frequent Itemsets:
FP-Growth – Conditional FP-tree Construction
FP-tree
For I3 null { }
L1 - Reordered
Itemset Support Node I2:4 I1:2
count Link
{I2} 7
TID List of items
{I1} 6 I1:2
T100 I1, I2, I5
{I3} 6 Eliminate
T200 I2, I4
{I4} 2
transactions not
T300 I2, I3
including I3
{I5} 2 T400 I1, I2, I4
T500 I1, I3
T600 I2, I3
Eliminate T700 I1, I3
I3 T800 I1, I2, I3, I5
T900 I1,
36I2, I3
11/6/2023
Mining Frequent Itemsets:
FP-Growth
I5 {{I2, I1: 1}, {I2, I1, I3: 1}} <I2:2, I1:2> {I2, I5: 2}, {I1, I5: 2},
{I2, I1, I5: 2}
I4 {{I2, I1: 1}, {I2: 1}} <I2:2> {I2, I4: 2}
I3 {{I2, I1: 2}, {I2: 2}, {I1: 2}} <I2:4, I1:2>, <I1:2> {I2, I3: 4}, {I1, I3: 4},
{I2, I1, I3: 2}
I1 {{I2: 4}} <I2:4> {I2, I1: 4}
37
Outline
The Basics
• Market Basket Analysis
• Frequent Item sets
• Association Rules
38
Pattern Evaluation Methods
39
Pattern Evaluation Methods
40