Pattern Mining: Advanced Methods
1
Mining Various Kinds of Patterns
2
Mining Multiple-Level Frequent Patterns
Uniform support
Level 1
min_sup = 5%
Level 2
min_sup = 5%
Level 1
min_sup = 5%
Level 2
min_sup = 1%
Reduced support
Milk
[support = 10%]
2% Milk
[support = 6%]
Skim Milk
[support = 2%]
3
Redundancy Filtering at Mining Multi-Level Associations
Q: If rule (1) is an ancestor of rule (2), which one to prune?
4
Customized Min-Supports for Different Kinds of Items
5
Mining Multi-Dimensional Associations
6
Mining Quantitative Associations
7
Mining Extraordinary Phenomena in Quantitative Association Mining
Efficient methods have been developed for mining such rules (e.g., Aumann and Lindell@KDD’99)
8
Rare Patterns vs. Negative Patterns
9
Defining Negative Correlated Patterns
—Null transactions: The support-based definition is not null-invariant!
Does this remind you the definition of lift?
10
Defining Negative Correlation: Need Null-Invariance in Definition
then A and B are negatively correlated
(s(A U B)/s(A) + s(A U B)/s(B))/2 = (0.01 + 0.01)/2 < є
є is a negative
pattern threshold
11
Pattern Mining: Advanced Methods
12
Mining Compressed Patterns
Pat-ID | Item-Sets | Support |
P1 | {38,16,18,12} | 205227 |
P2 | {38,16,18,12,17} | 205211 |
P3 | {39,38,16,18,12,17} | 101758 |
P4 | {39,16,18,12,17} | 161563 |
P5 | {39,16,18,12} | 161576 |
13
Redundancy-Aware Top-k Patterns
14
Pattern Mining: Advanced Methods
15
Why Constraint-Based Mining?
16
Various Kinds of User-Specified Constraints in Data Mining
The focus of this study
17
Pattern Space Pruning with Pattern Anti-Monotonicity
min_sup = 2
TID | Transaction |
10 | a, b, c, d, f, h |
20 | b, c, d, f, g, h |
30 | b, c, d, f, g |
40 | a, c, e, f, g |
Item | Price | Profit |
a | 100 | 40 |
b | 40 | 0 |
c | 150 | −20 |
d | 35 | −15 |
e | 55 | −30 |
f | 45 | −10 |
g | 80 | 20 |
h | 10 | 5 |
Note: item.price > 0
Profit can be negative
18
Pattern Monotonicity and Its Roles
min_sup = 2
TID | Transaction |
10 | a, b, c, d, f, h |
20 | b, c, d, f, g, h |
30 | b, c, d, f, g |
40 | a, c, e, f, g |
Item | Price | Profit |
a | 100 | 40 |
b | 40 | 0 |
c | 150 | −20 |
d | 35 | −15 |
e | 55 | −30 |
f | 45 | −10 |
g | 80 | 20 |
h | 10 | 5 |
19
Apriori for Pattern Anti-Monotone Constraint
Database D
Scan D
C1
F1
F2
C2
C2
Scan D
C3
F3
Scan D
Min_sup=2
Constraint:
Sum{S.price} < 5
Item | Price |
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
Can be chopped early
20
Convertible Constraints: Ordering Data in Transactions
min_sup = 2
TID | Transaction |
10 | a, b, c, d, f, h |
20 | a, b, c, d, f, g, h |
30 | b, c, d, f, g |
40 | a, c, e, f, g |
Item | Price | Profit |
a | 100 | 40 |
b | 40 | 0 |
c | 150 | −20 |
d | 35 | −15 |
e | 55 | −30 |
f | 45 | −5 |
g | 80 | 30 |
h | 10 | 5 |
21
Can item-reordering work for Apriori?
min_sup = 2
TID | Transaction |
10 | a, b, c, d, f, h |
20 | a, b, c, d, f, g, h |
30 | b, c, d, f, g |
40 | a, c, e, f, g |
Item | Price | Profit |
a | 100 | 40 |
b | 40 | 0 |
c | 150 | −20 |
d | 35 | −15 |
e | 55 | −30 |
f | 45 | −5 |
g | 80 | 30 |
h | 10 | 5 |
Scan D
F1
F2
Chopped too early
constraint: avg(S.profit) > 20
22
Data Space Pruning with Data Anti-Monotonicity
min_sup = 2
TID | Transaction |
10 | a, b, c, d, f, h |
20 | b, c, d, f, g, h |
30 | b, c, d, f, g |
40 | a, c, e, f, g |
Item | Price | Profit |
a | 100 | 40 |
b | 40 | 0 |
c | 150 | −20 |
d | 35 | −15 |
e | 55 | −30 |
f | 45 | −10 |
g | 80 | 20 |
h | 10 | 5 |
23
Data Space Pruning Should Be Explored Recursively
min_sup = 2
TID | Transaction |
10 | a, b, c, d, f, h |
20 | b, c, d, f, g, h |
30 | b, c, d, f, g |
40 | a, c, e, f, g |
Item | Profit |
a | 40 |
b | 0 |
c | −20 |
d | −15 |
e | −30 |
f | −10 |
g | 20 |
h | 5 |
b’s-proj. DB
TID | Transaction |
10 | a, c, d, f, h |
20 | c, d, f, g, h |
30 | c, d, f, g |
TID | Transaction |
10 | a, c, d, f, h |
20 | c, d, f, g, h |
30 | c, d, f, g |
b’s-proj. DB
24
Data Space Pruning Explored Recursively (Continued)
TID | Transaction |
10 | a, c, d, f, h |
20 | c, d, f, g, h |
30 | c, d, f, g |
Recursive
Data
Pruning
b’s FP-tree
single branch: cdfg: 2
Constraint:
range{S.profit} > 25
Only a single branch “cdfg: 2” to be mined in b’s projected DB
b’s-proj. DB
25
Succinctness: Pruning Both Data and Pattern Spaces
26
Constrained FP-Growth: Push a Succinct Constraint Deep
Remove
infrequent
length 1
1-Projected DB
No Need to project on 3 or 5
Item | Price |
1 | 1 |
2 | 2 |
3 | 3 |
4 | 4 |
5 | 5 |
2-Projected DB
Min_sup=2
Constraint:
min{S.price} <= 2
TID | Items |
20 | 3 5 |
30 | 1 3 5 |
40 | 5 |
27
Different Kinds of Constraints Lead to Different Pruning Strategies
Pattern space pruning constraints | Data space pruning constraints |
|
|
28
How to Handle Multiple Constraints?
29
Pattern Mining: Advanced Methods
30
Sequential Pattern Mining
31
Sequential Pattern Mining
32
Sequential Pattern Examples
33
Sequential Pattern and Sequential Pattern Mining
A sequence database
* Items within an element are unordered and we list them alphabetically
A sequence: < (ef) (ab) (df) c b >
SID | Sequence |
10 | <a(abc)(ac)d(cf)> |
20 | <(ad)c(bc)(ae)> |
30 | <(ef)(ab)(df)cb> |
40 | <eg(af)cbc> |
element (unordered within “(..)”)
34
Sequential Pattern and Sequential Pattern Mining
<a(bc)dc> is a subsequence of <a(abc)(ac)d(cf)>
SID | Sequence |
10 | <a(abc)(ac)d(cf)> |
20 | <(ad)c(bc)(ae)> |
30 | <(ef)(ab)(df)cb> |
40 | <eg(af)cbc> |
A sequence database
35
Sequential Pattern Mining Algorithms
36
GSP: Apriori-Based Sequential Pattern Mining
SID | Sequence |
10 | <(bd)cb(ac)> |
20 | <(bf)(ce)b(fg)> |
30 | <(ah)(bf)abf> |
40 | <(be)(ce)d> |
50 | <a(bd)bcb(ade)> |
min_sup = 2
Cand. | sup |
<a> | 3 |
<b> | 5 |
<c> | 4 |
<d> | 3 |
<e> | 3 |
<f> | 2 |
<g> | 1 |
<h> | 1 |
x
GSP (Generalized Sequential Patterns): Srikant & Agrawal @ EDBT’96)
37
GSP: Apriori-Based Sequential Pattern Mining
min_sup = 2
Cand. | sup |
<a> | 3 |
<b> | 5 |
<c> | 4 |
<d> | 3 |
<e> | 3 |
<f> | 2 |
<g> | 1 |
<h> | 1 |
| <a> | <b> | <c> | <d> | <e> | <f> |
<a> | <aa> | <ab> | <ac> | <ad> | <ae> | <af> |
<b> | <ba> | <bb> | <bc> | <bd> | <be> | <bf> |
<c> | <ca> | <cb> | <cc> | <cd> | <ce> | <cf> |
<d> | <da> | <db> | <dc> | <dd> | <de> | <df> |
<e> | <ea> | <eb> | <ec> | <ed> | <ee> | <ef> |
<f> | <fa> | <fb> | <fc> | <fd> | <fe> | <ff> |
| <a> | <b> | <c> | <d> | <e> | <f> |
<a> | | <(ab)> | <(ac)> | <(ad)> | <(ae)> | <(af)> |
<b> | | | <(bc)> | <(bd)> | <(be)> | <(bf)> |
<c> | | | | <(cd)> | <(ce)> | <(cf)> |
<d> | | | | | <(de)> | <(df)> |
<e> | | | | | | <(ef)> |
<f> | | | | | | |
8*8 + 8*7/2 = 92
length-2 candidates
6*6 + 6*5/2 = 51
length-2 candidates
singleton * singleton – Total: (6 * 6)
Sets (unordered) – Total: (6*5) / 2
Apriori Pruning
38
GSP Mining and Pruning
<a> <b> <c> <d> <e> <f> <g> <h>
<aa> <ab> … <af> <ba> <bb> … <ff> <(ab)> … <(ef)>
<abb> <aab> <aba> <baa> <bab> …
<abba> <(bd)bc> …
<(bd)cba>
1st scan: 8 cand. 6 length-1 seq. pat.
2nd scan: 51 cand. 19 length-2 seq. pat. 10 cand. not in DB at all
3rd scan: 46 cand. 20 length-3 seq. pat. 20 cand. not in DB at all
4th scan: 8 cand. 7 length-4 seq. pat.
5th scan: 1 cand. 1 length-5 seq. pat.
SID | Sequence |
10 | <(bd)cb(ac)> |
20 | <(bf)(ce)b(fg)> |
30 | <(ah)(bf)abf> |
40 | <(be)(ce)d> |
50 | <a(bd)bcb(ade)> |
min_sup = 2
6*6 + 6*5/2 = 51
length
5
4
3
2
1
The GPS algorithm
39
Sequential Pattern Mining in Vertical Data Format: The SPADE Algorithm
SID | Sequence |
1 | <a(abc)(ac)d(cf)> |
2 | <(ad)c(bc)(ae)> |
3 | <(ef)(ab)(df)cb> |
4 | <eg(af)cbc> |
Ref: SPADE (Sequential PAttern Discovery using Equivalent Class) [M. Zaki 2001]
min_sup = 2
EID (b) < EID (a):
Corresponds to:
<a(abc)(ac)d(cf)>
40
PrefixSpan: A Pattern-Growth Approach
SID | Sequence |
10 | <a(abc)(ac)d(cf)> |
20 | <(ad)c(bc)(ae)> |
30 | <(ef)(ab)(df)cb> |
40 | <eg(af)cbc> |
Prefix | Suffix (Projection) |
<a> | <(abc)(ac)d(cf)> |
<aa> | <(_bc)(ac)d(cf)> |
<ab> | <(_c)(ac)d(cf)> |
PrefixSpan (Prefix-projected Sequential pattern mining) Pei, et al. @TKDE’04
min_sup = 2
“_” is placeholder for prefix
41
PrefixSpan: Mining Prefix-Projected DBs
prefix <a>
Length-1 sequential patterns
<a>, <b>, <c>, <d>, <e>, <f>
prefix <aa>
…
prefix <af>
…
prefix <b>
prefix <c>, …, <f>
… …
SID | Sequence |
10 | <a(abc)(ac)d(cf)> |
20 | <(ad)c(bc)(ae)> |
30 | <(ef)(ab)(df)cb> |
40 | <eg(af)cbc> |
<a>-projected DB |
<(abc)(ac)d(cf)> |
<(_d)c(bc)(ae)> |
<(_b)(df)cb> |
<(_f)cbc> |
<aa>-projected DB |
<af>-projected DB |
Major strength of PrefixSpan:
min_sup = 2
<b>-projected DB |
<(_c)(ac)d(cf)> |
<(_c)(ae)> |
<(df)cb> |
<c> |
Length-2 sequential
patterns
<aa>, <ab>, <(ab)>,
<ac>, <ad>, <af>
42
Implementation Consideration: Pseudo-Projection vs. Physical Projection
s = <a(abc)(ac)d(cf)>
<(abc)(ac)d(cf)>
<(_c)(ac)d(cf)>
<a>
<ab>
s|<a>: ( , 2)
s|<ab>: ( , 5)
2 5
Pointers save memory usage
43
CloSpan: Mining Closed Sequential Patterns
44
CloSpan: When Two Projected DBs Have the Same Size
<efbcg> |
<fegb(ac)> |
<fea> |
<e>
<a>
<f>
<b>
ID | Sequence |
1 | <aefbcg> |
2 | <afegb(ac)> |
3 | <afea> |
<bcg> |
<egb(ac)> |
<ea> |
<cg> |
<(ac)> |
<fbcg> |
<gb(ac)> |
<a> |
<b>
<cg> |
<(ac)> |
<f>
<bcg> |
<egb(ac)> |
<ea> |
Only need to keep size = 12 (including parentheses)
size = 6
Backward subpattern pruning
Backward superpattern pruning
min_sup = 2
45
Constraint-Based Sequential-Pattern Mining
46
Timing-Based Constraints in Seq.-Pattern Mining
47
Episodes and Episode Pattern Mining
a partial order relationship: A and B can be in any order
a total order relationship: first A then B
(DE) means D, E happen in the same time window
48
Pattern Mining: Advanced Methods
49
What Is Graph Pattern Mining?
50
Frequent (Sub)Graph Patterns
Graph Dataset
Frequent Graph Patterns
(A)
(B)
(C)
(1)
(2)
min_sup = 2
support = 67%
51
Applications of Graph Pattern Mining
52
Graph Pattern Mining Algorithms: Different Methodologies
53
Apriori-Based Approach
…
G
G1
G2
Gn
k-edge
(k+1)-edge
G’
G’’
Join
54
Candidate Generation: �Vertex Growing vs. Edge Growing
55
Pattern-Growth Approach
…
G
G1
G2
Gn
k-edge
(k+1)-edge
…
(k+2)-edge
…
duplicate
graphs
56
gSPAN: Graph Pattern Growth in Order
0
1
2
3
4
e0: (0,1)
e1: (1,2)
e2: (2,3)
e3: (3,0)
e4: (2,4)
57
Why Mine Closed Graph Patterns?
If this subgraph is closed in the graph dataset, it implies that none of its frequent super-graphs carries the same support
58
CloseGraph: Directly Mining Closed Graph Patterns
…
G
G1
G2
Gn
k-edge
(k+1)-edge
At what condition can we
stop searching their children,
i.e., early termination?
59
Experiment and Performance Comparison
20%
10%
5%
Minimum support
Number of patterns
# of Patterns: Frequent vs. Closed
Run time (sec)
Runtime: Frequent vs. Closed
Minimum support
60
Application of Pattern Mining I: Graph Indexing
Graph (G)
Substructure
Query graph (Q)
Graph DB:
(a)
(b)
(c)
Path-indices: C, C-C, C-C-C, C-C-C-C cannot prune (a) & (b)
Only graph (c) contains Q
Query Q:
61
gIndex: Indexing Frequent and Discriminative Substructures
size
support
min-support threshold
when Pr(x|f1, f2, …, fn) is small enough, x is a discriminative structure and should be included in the index
62
Application II: Support Substructure Similarity Search
(a)
(b)
(c)
63
Feature-Based Similarity Search
Substructure
Graph (G1)
Graph (G2)
Query (q)
Assume: Query graph has 5 features
Relaxation threshold: Can miss at most 2 features
Then: G1, G2, G3 are pruned
| G1 | G2 | G3 | G4 | G5 |
f1 | 0 | 1 | 0 | 1 | 1 |
f2 | 0 | 1 | 0 | 0 | 1 |
f3 | 1 | 0 | 1 | 1 | 1 |
f4 | 1 | 0 | 0 | 0 | 1 |
f5 | 0 | 0 | 1 | 1 | 0 |
Graphs in database
features
A feature-graph matrix
64
Pattern Mining: Advanced Methods
65
Pattern Mining Application I: Software Bug Detection
66
Application Example: Mining Copy-and-Paste Bugs
void __init prom_meminit(void)
{
……
for (i=0; i<n; i++) {
total[i].adr = list[i].addr;
total[i].bytes = list[i].size;
total[i].more = &total[i+1];
}
……
for (i=0; i<n; i++) {
taken[i].adr = list[i].addr;
taken[i].bytes = list[i].size;
taken[i].more = &total[i+1];
}
(Simplified example from linux-2.6.6/arch/sparc/prom/memory.c)
Code copy-and- pasted but forget to change “id”!
Courtesy of Yuanyuan Zhou@UCSD
67
Building Sequence Database from Source Code
old = 3;
5 61 20
Tokenize
Hash
16
new = 3;
5 61 20
16
Map a statement to a number
Final sequence DB:�(65)�(16, 16, 71)�…�(65)�(16, 16, 71)
for (i=0; i<n; i++) {
total[i].adr = list[i].addr;
total[i].bytes = list[i].size;
total[i].more = &total[i+1];
}� ……��for (i=0; i<n; i++) {
taken[i].adr = list[i].addr;
taken[i].bytes = list[i].size;
taken[i].more = &total[i+1];
}
65�16�16�71��…��65
16
16
71
Hash values
Courtesy of Yuanyuan Zhou@UCSD
(mapped to)
68
Sequential Pattern Mining & Detecting “Forget-to-Change” Bugs
Courtesy of Yuanyuan Zhou@UCSD
f (a1);
f (a2);
f (a3);
f1 (b1);
f1 (b2);
f2 (b3);
conflict
(16, 16, 71)�……�(16, 16, 10, 71)
Allow a maximal gap: inserting statements in copy-and-paste
69
Why Phrase Mining?
70
From Frequent Pattern Mining to Phrase Mining
71
ToPMine: Phrase Mining before Topic Modeling
Phrase | Raw frequency | Rectified frequency |
[support vector machine] | 90 | 80 |
[vector machine] | 95 | 0 |
[support vector] | 100 | 5 |
72
Collocation Mining
73
Phrase Candidate Generation: Frequent Pattern Mining + Statistical Analysis
[Markov blanket] [feature selection] for [support vector machines] |
[knowledge discovery] using [least squares] [support vector machine] [classifiers] |
…[support vector] for [machine learning]… |
Quality phrases
Based on significance score [Church et al.’91]:
α(P1, P2) ≈ (f(P1●P2) ̶ µ0(P1,P2))/√ f(P1●P2)
Note for the first title:
74
ToPMine: Experiments on DBLP Abstracts
ToPMine is efficient and generates high-quality topics and phrases without any training data
75
ToPMine: Experiments on Yelp Reviews
ToPMine works well for phrase and topic mining in social media data
76
SagPhrase: Phrase Mining with Tiny Training Sets
J. Liu et al., Mining Quality Phrases from Massive Text Corpora. In SIGMOD’15
Document 1
Citation recommendation is an interesting but challenging research problem in data mining area.
Document 2
In this study, we investigate the problem in the context of heterogeneous information networks using data mining technique.
Phrase Mining
Document 3
Principal Component Analysis is a linear dimensionality reduction technique commonly used in machine learning applications.
Quality Phrases
Phrasal Segmentation
Raw Corpus
Segmented Corpus
Input Raw Corpus
Quality Phrases
Segmented Corpus
+ A small set of labels by human or a general KB
Integrating phrase mining with phrasal segmentation and classification
77
SegPhrase+: The Overall Framework
ClassPhrase
SegPhrase(+)
SegPhrase (a classifier is used)
Small labeled dataset
provided by experts
or
a distant supervised KB (e.g., Wikipedia / DBPedia)
78
SegPhrase: Pattern Mining and Feature Extraction
79
SegPhrase: Classification Using Tiny Training Sets
Not counted towards the rectified frequency
80
Performance: Precision Recall Curves on DBLP
Dataset | #docs | #words | #labels |
DBLP | 2.77M | 91.6M | 300 |
Yelp | 4.75M | 145.1M | 300 |
Precision-Recall Curves on DBLP Data (Wiki Phrases)
Precision-Recall Curves on DBLP Data (Non Wiki-phrases)
Use only 300 human labeled phrases for training
81
Experimental Results: Interesting Phrases�Generated (From Titles & Abstracts of SIGKDD)
Query | SIGKDD | |
Method | SegPhrase+ | Chunking (TF-IDF & C-Value) |
1 | data mining | data mining |
2 | data set | association rule |
3 | association rule | knowledge discovery |
4 | knowledge discovery | frequent itemset |
5 | time series | decision tree |
… | … | … |
51 | association rule mining | search space |
52 | rule set | domain knowledge |
53 | concept drift | important problem |
54 | knowledge acquisition | concurrency control |
55 | gene expression data | conceptual graph |
… | … | … |
201 | web content | optimal solution |
202 | frequent subgraph | semantic relationship |
203 | intrusion detection | effective way |
204 | categorical attribute | space complexity |
205 | user preference | small set |
… | … | … |
Only in SegPhrase+
Only in Chunking
82
Mining Quality Phrases in Multiple Languages
كفروا 🡪 Those who disbelieve
بسم الله الرحمن الرحيم🡪 In the name of God the Gracious and Merciful
Rank | Phrase | In English |
… | … | … |
62 | 首席_执行官 | CEO |
63 | 中间_偏右 | Middle-right |
… | … | … |
84 | 百度_百科 | Baidu Pedia |
85 | 热带_气旋 | Tropical cyclone |
86 | 中国科学院_院士 | Fellow of Chinese Academy of Sciences |
… | … | … |
1001 | 十大_中文_金曲 | Top-10 Chinese Songs |
1002 | 全球_资讯网 | Global News Website |
1003 | 天一阁_藏_明代_科举_录_选刊 | A Chinese book name |
… | … | … |
9934 | 国家_戏剧_院 | National Theater |
9935 | 谢谢_你 | Thank you |
… | … | … |
83
AutoPhrase: Automated Phrase Mining by Distant Supervision
84
Robust Positive-Only Distant Training
85
Why Is Positive-Only Distant Training Robust?
Note: AUC (Area Under Curve), with value range [0,1], is a classification measure to be introduced in the classification module
86
Modeling Single-Word Phrases: Enhancing Recall
87
AutoPhrase: Cross-Domain Evaluation Results
88
Computer Science Papers
Yelp Business Reviews
Wikipedia Articles
SegPhrase (SIGMOD’15): Outperformed TopMine (VLDB’15) and many other methods
TF-IDF: Stanford NLP Parser (LREC’16) + Ranked by TF-IDF
TextRank (ACL’04): Stanford NLP Parser (LREC’16) + Ranked by TextRank
AutoPhrase (TKDE’18): Best performing and generating multi-word and single word phrases
88
AutoPhrase: Cross-Language Evaluation Results
English
Spanish
Chinese
WrapSegPhrase: non-English characters 🡪 English letters & SegPhrase
JiebaSeg: Specifically for Chinese; Dictionaries & Hidden Markov Models
AnsjSeg: Specifically for Chinese; Dictionaries & Conditional Random Fields
AutoPhrase (TKDE’18): Best performing and generating multi-word and single word phrases
89
90
Phrase’s Rank | Phrase | Translation (Explanation) |
1 | 江苏_舜_天 | (the name of a soccer team) |
2 | 苦_艾_酒 | Absinthe |
3 | 白发_魔_女 | (the name of a novel/TV-series) |
4 | 笔记_型_电脑 | notebook computer, laptop |
5 | 首席_执行官 | CEO |
… | … | … |
99,994 | 计算机_科学技术 | Computer Science and Technology |
99,995 | 恒_天然 | Fonterra (a company) |
99,996 | 中国_作家_协会_副_主席 | The Vice President of Writers Association of China |
99,997 | 维他命_b | Vitamin B |
99,998 | 舆论_导向 | controlled guidance of the media |
… | … | … |
AutoPhrase: An Example Run From Chinese Wikipedia
90
Pattern Mining: Advanced Methods
91
Summary: Pattern Mining: Advanced Methods (I)
92
Summary: Pattern Mining: Advanced Methods (II)
93
References: Mining Diverse Patterns
94
References: Constraint-Based Frequent Pattern Mining
95
References: Sequential Pattern Mining
96
References: Graph Pattern Mining
97
References: Phrase Mining
98