Mining Frequent Patterns, Association and Correlations�( Basic Concepts and Methods)
1
1
Mining Frequent Patterns, Association and Correlations�( Basic Concepts and Methods)
2
What Is Frequent Pattern Analysis?
3
Why Is Freq. Pattern Mining Important?
4
Basic Concepts: Frequent Patterns
5
Customer
buys diaper
Customer
buys both
Customer
buys beer
Tid | Items bought |
10 | Beer, Nuts, Diaper |
20 | Beer, Coffee, Diaper |
30 | Beer, Diaper, Eggs |
40 | Nuts, Eggs, Milk |
50 | Nuts, Coffee, Diaper, Eggs, Milk |
Basic Concepts: Association Rules
Let minsup = 50%, minconf = 50%
Freq. Pat.: Beer:3, Nuts:3, Diaper:4, Eggs:3, {Beer, Diaper}:3
6
Customer
buys diaper
Customer
buys both
Customer
buys beer
Nuts, Eggs, Milk
40
Nuts, Coffee, Diaper, Eggs, Milk
50
Beer, Diaper, Eggs
30
Beer, Coffee, Diaper
20
Beer, Nuts, Diaper
10
Items bought
Tid
Closed Patterns and Max-Patterns
7
Closed Patterns and Max-Patterns
8
Computational Complexity of Frequent Itemset Mining
9
Chapter 5: Mining Frequent Patterns, Association and Correlations: Basic Concepts and Methods
10
Scalable Frequent Itemset Mining Methods
11
The Downward Closure Property and Scalable Mining Methods
12
Apriori: A Candidate Generation & Test Approach
13
The Apriori Algorithm—An Example
14
Database TDB
1st scan
C1
L1
L2
C2
C2
2nd scan
C3
L3
3rd scan
Tid | Items |
10 | A, C, D |
20 | B, C, E |
30 | A, B, C, E |
40 | B, E |
Itemset | sup |
{A} | 2 |
{B} | 3 |
{C} | 3 |
{D} | 1 |
{E} | 3 |
Itemset | sup |
{A} | 2 |
{B} | 3 |
{C} | 3 |
{E} | 3 |
Itemset |
{A, B} |
{A, C} |
{A, E} |
{B, C} |
{B, E} |
{C, E} |
Itemset | sup |
{A, B} | 1 |
{A, C} | 2 |
{A, E} | 1 |
{B, C} | 2 |
{B, E} | 3 |
{C, E} | 2 |
Itemset | sup |
{A, C} | 2 |
{B, C} | 2 |
{B, E} | 3 |
{C, E} | 2 |
Itemset |
{B, C, E} |
Itemset | sup |
{B, C, E} | 2 |
Supmin = 2
The Apriori Algorithm (Pseudo-Code)
Ck: Candidate itemset of size k
Lk : frequent itemset of size k
L1 = {frequent items};
for (k = 1; Lk !=∅; k++) do begin
Ck+1 = candidates generated from Lk;
for each transaction t in database do
increment the count of all candidates in Ck+1 that are contained in t
Lk+1 = candidates in Ck+1 with min_support
end
return ∪k Lk;
15
Implementation of Apriori
16
How to Count Supports of Candidates?
17
Counting Supports of Candidates Using Hash Tree
18
1,4,7
2,5,8
3,6,9
Subset function
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
Transaction: 1 2 3 5 6
1 + 2 3 5 6
1 2 + 3 5 6
1 3 + 5 6
Candidate Generation: An SQL Implementation
insert into Ck
select p.item1, p.item2, …, p.itemk-1, q.itemk-1
from Lk-1 p, Lk-1 q
where p.item1=q.item1, …, p.itemk-2=q.itemk-2, p.itemk-1 < q.itemk-1
forall itemsets c in Ck do
forall (k-1)-subsets s of c do
if (s is not in Lk-1) then delete c from Ck
19
Scalable Frequent Itemset Mining Methods
20
Further Improvement of the Apriori Method
21
Partition: Scan Database Only Twice
DB1
DB2
DBk
+
= DB
+
+
sup1(i) < σDB1
sup2(i) < σDB2
supk(i) < σDBk
sup(i) < σDB
DHP: Reduce the Number of Candidates
23
count
itemsets
35
{ab, ad, ae}
{yz, qs, wt}
88
102
...
{bd, be, de}
...
Hash Table
Sampling for Frequent Patterns
24
DIC: Reduce Number of Scans
25
ABCD
ABC
ABD
ACD
BCD
AB
AC
BC
AD
BD
CD
A
B
C
D
{}
Itemset lattice
Transactions
1-itemsets
2-itemsets
…
Apriori
1-itemsets
2-items
3-items
DIC
S. Brin R. Motwani, J. Ullman, and S. Tsur. Dynamic itemset counting and implication rules for market basket data. SIGMOD’97
Scalable Frequent Itemset Mining Methods
26
Pattern-Growth Approach: Mining Frequent Patterns Without Candidate Generation
27
Construct FP-tree from a Transaction Database
28
{}
f:4
c:1
b:1
p:1
b:1
c:3
a:3
b:1
m:2
p:2
m:1
Header Table
Item frequency head
f 4
c 4
a 3
b 3
m 3
p 3
min_support = 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, w} {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}
F-list = f-c-a-b-m-p
Partition Patterns and Databases
29
Find Patterns Having P From P-conditional Database
30
Conditional pattern bases
item cond. pattern base
c f:3
a fc:3
b fca:1, f:1, c:1
m fca:2, fcab:1
p fcam:2, cb:1
{}
f:4
c:1
b:1
p:1
b:1
c:3
a:3
b:1
m:2
p:2
m:1
Header Table
Item frequency head
f 4
c 4
a 3
b 3
m 3
p 3
From Conditional Pattern-bases to Conditional FP-trees
31
m-conditional pattern base:
fca:2, fcab:1
{}
f:3
c:3
a:3
m-conditional FP-tree
All frequent patterns relate to m
m,
fm, cm, am,
fcm, fam, cam,
fcam
🡲
🡲
{}
f:4
c:1
b:1
p:1
b:1
c:3
a:3
b:1
m:2
p:2
m:1
Header Table
Item frequency head
f 4
c 4
a 3
b 3
m 3
p 3
Recursion: Mining Each Conditional FP-tree
32
{}
f:3
c:3
a:3
m-conditional FP-tree
Cond. pattern base of “am”: (fc:3)
{}
f:3
c:3
am-conditional FP-tree
Cond. pattern base of “cm”: (f:3)
{}
f:3
cm-conditional FP-tree
Cond. pattern base of “cam”: (f:3)
{}
f:3
cam-conditional FP-tree
A Special Case: Single Prefix Path in FP-tree
33
🡲
a2:n2
a3:n3
a1:n1
{}
b1:m1
C1:k1
C2:k2
C3:k3
b1:m1
C1:k1
C2:k2
C3:k3
r1
+
a2:n2
a3:n3
a1:n1
{}
r1
=
Benefits of the FP-tree Structure
34
The Frequent Pattern Growth Mining Method
35
Scaling FP-growth by Database Projection
36
Partition-Based Projection
37
Tran. DB
fcamp
fcabm
fb
cbp
fcamp
p-proj DB
fcam
cb
fcam
m-proj DB
fcab
fca
fca
b-proj DB
f
cb
…
a-proj DB
fc
…
c-proj DB
f
…
f-proj DB
…
am-proj DB
fc
fc
fc
cm-proj DB
f
f
f
…
Performance of FPGrowth in Large Datasets
FP-Growth vs. Apriori
38
Data set T25I20D10K
Data set T25I20D100K
FP-Growth vs. Tree-Projection
Advantages of the Pattern Growth Approach
39
Further Improvements of Mining Methods
40
Extension of Pattern Growth Mining Methodology
41
Scalable Frequent Itemset Mining Methods
42
ECLAT: Mining by Exploring Vertical Data Format
43
Scalable Frequent Itemset Mining Methods
44
Mining Frequent Closed Patterns: CLOSET
TID | Items |
10 | a, c, d, e, f |
20 | a, b, e |
30 | c, e, f |
40 | a, c, d, f |
50 | c, e, f |
Min_sup=2
CLOSET+: Mining Closed Itemsets by Pattern-Growth
MaxMiner: Mining Max-Patterns
Tid | Items |
10 | A, B, C, D, E |
20 | B, C, D, E, |
30 | A, C, D, F |
Potential max-patterns
CHARM: Mining by Exploring Vertical Data Format
49
Visualization of Association Rules: Plane Graph
50
Visualization of Association Rules: Rule Graph
Visualization of Association Rules �(SGI/MineSet 3.0)
51
Chapter 5: Mining Frequent Patterns, Association and Correlations: Basic Concepts and Methods
52
Interestingness Measure: Correlations (Lift)
53
| Basketball | Not basketball | Sum (row) |
Cereal | 2000 | 1750 | 3750 |
Not cereal | 1000 | 250 | 1250 |
Sum(col.) | 3000 | 2000 | 5000 |
Are lift and χ2 Good Measures of Correlation?
54
Null-Invariant Measures
55
Comparison of Interestingness Measures
*
Data Mining: Concepts and Techniques
56
| Milk | No Milk | Sum (row) |
Coffee | m, c | ~m, c | c |
No Coffee | m, ~c | ~m, ~c | ~c |
Sum(col.) | m | ~m | Σ |
Null-transactions w.r.t. m and c
Null-invariant
Subtle: They disagree
Kulczynski measure (1927)
Analysis of DBLP Coauthor Relationships
57
Advisor-advisee relation: Kulc: high, coherence: low, cosine: middle
Recent DB conferences, removing balanced associations, low sup, etc.
Which Null-Invariant Measure Is Better?
Chapter 5: Mining Frequent Patterns, Association and Correlations: Basic Concepts and Methods
59
Summary
60
Ref: Basic Concepts of Frequent Pattern Mining
61
Ref: Apriori and Its Improvements
62
Ref: Depth-First, Projection-Based FP Mining
63
Ref: Vertical Format and Row Enumeration Methods
64
Ref: Mining Correlations and Interesting Rules
65