挖掘關聯式規則 Data Mining 資料探勘 Course 3

Download Report

Transcript 挖掘關聯式規則 Data Mining 資料探勘 Course 3

Course 3
挖掘關聯式規則
Mining Association Rules
Data Mining
資料探勘
國立聯合大學 資訊管理學系 陳士杰老師
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
 Outlines

關聯分析的基本概念與準則 (Basic Concepts and Road
Map)

有效率且可行的頻繁項目集挖掘方法 (Efficient and
scalable frequent itemset mining methods)

挖掘多樣化的關聯規則 (Mining various kinds of association
rules)

從關聯挖掘到相關性分析 (From association mining to
correlation analysis)

具有限制的關聯挖掘 (Constraint-based association mining)

Summary
2
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
 Basic Concepts and a Road Map

Frequent pattern: a pattern (a set of items,
subsequences, substructures, etc.) that occurs frequently
in a data set

Motivation: Finding inherent regularities in data

What products were often purchased together?— Beer and
diapers?!

What are the subsequent purchases after buying a PC?

What kinds of DNA are sensitive to this new drug?

Can we automatically classify web documents?
3
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
“尿布與啤酒”──典型關聯分析案例


在美國,一些年輕的父親下班後經常要到超市去
買嬰兒尿布,超市也因此發現了一個規律,在購
買嬰兒尿布的年輕父親們中,有30%~40%的人
同時要買一些啤酒。超市隨後調整了貨架的擺放,
把尿布和啤酒放在一起,明顯增加了銷售額。
同樣的,我們還可以根據關聯規則在商品銷售方
面做各種促銷活動。
 Applications

Basket data analysis, cross-marketing, sale campaign
analysis, and DNA sequence analysis.
4
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
5
國立聯合大學 資訊管理學系

資料探勘課程 (陳士杰)
如果問題的全域是商店中所有商品的集合,則對每種商品
都可以用一個布林量來表示該商品是否被顧客購買,則每
個購物籃都可以用一個布林向量表示;而透過分析布林向
量則可以得到商品被頻繁關聯或被同時購買的模式,這些
模式就可以用關聯規則表示。
(0001001100,這種方法失去了什麼訊息?)
6
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
What Is Association Mining?

Association rule mining:


Finding frequent patterns, associations, correlations, or causal
structures among sets of items or objects in transaction databases,
relational databases, and other information repositories.
Examples.

Rule form: “Body  Head [support, confidence]”.

buys(x, “diapers”)  buys(x, “beers”) [0.5%, 60%]

major(x, “CS”) ^ takes(x, “DB”)  grade(x, “A”) [1%, 75%]
7
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Association Rule: Basic Concepts


給定︰

Items set: I={i1,i2,...,im}

The task-relevant data D: 是資料庫交易的集合,每個
交易T則是項目的集合,使得 T  I

每個交易由交易識別符號TID標識;

A, B為兩個項目集合,交易T包含A if and only if A  T
關聯規則是如下蘊涵式︰
AB

[s, c]
其中 A  I, B  I 並且 A  B  Φ ,規則 A  B 在資料集
D中成立,並且具有支持度s和置信度c
8
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
9
範例


項目集合 I={A,B,C,D,E,F}
每個交易T由交易識別符號TID標識,它是項目集合


比如︰TID(2000)={A,B,C}
任務相關資料D是資料庫交易的集合
TID
2000
1000
4000
5000
購買的item
A,B,C
A,C
A,D
B,E,F
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
10
Terminologies

Item



Itemset



{I1}, {I2}, {A}, …
2-Itemset


{I1}, {I1, I7}, {I2, I3, I5}, …
{A}, {A, G}, {B, C, E}, …
1-Itemset


I1, I2, I3, …
A, B, C, …
{I1, I7}, {I3, I5}, {A, G}, …
K-itemset
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
11
Rule Measures: Support and Confidence
Customer
buys both
Customer
buys diaper A

Find all the rules A  B with
minimum confidence and support


Customer
buys beer B
Transaction ID Items Bought
2000
A,B,C
1000
A,C
4000
A,D
5000
B,E,F

support, s, probability that a
transaction contains {A ∪ B}
confidence, c, conditional
probability that a transaction having
{A} also contains B
Let minimum support 50%, and
minimum confidence 50%, we
have:


A  C (50%, 66.6%)
C  A (50%, 100%)
國立聯合大學 資訊管理學系



最小support控制了一個規則必須涵蓋的最少資料數目
最小的confidence則控制了這個規則的預測強度
當挖掘演算法找出滿足使用者訂定的最小support和confidence的關連規則,
這個規則才算成立。
舉例來說,如果要產生A  B(當發生A時,則會發生B)的關連規則
時,我們所需要找出的itemsets便是{AB},如果:



12
在探討關連規則的挖掘之前,我們必須先了解:


資料探勘課程 (陳士杰)
我們設定最小support值為40%,且資料庫中有10,000筆交易記錄,則
{AB}這個itemsets所出現的筆數必須大於等於4,000(10,00040%)才算
frequent itemsets(又稱large itemsets)
在{A}出現的所有記錄中,{B}也同時出現的比例,便是A  B這個關連
規則的confidence,假設我們設定的最小confidence值為60%,則{AB}出
現的次數除以所有含有{A}的記錄數目所得的比例,若大於等於60%,則
表示這一個規則成立。
上述的例子我們若以數學式來表示,support便是P(A ∪ B)的機率,
confidence則是以條件機率P(B|A)表示,可整理成下面的式子:


support(AÞB) = P(A ∪ B)
confidence(AÞB) = P(B|A)
國立聯合大學 資訊管理學系

資料探勘課程 (陳士杰)
大型資料庫中的關聯規則挖掘包含兩個過程︰

找出所有頻繁項目集


大部分的計算都集中在這一步
由頻繁項目集產生強關聯規則

即滿足最小支持度和最小置信度的規則
13
國立聯合大學 資訊管理學系

資料探勘課程 (陳士杰)
Given:
(1) database of transactions (交易資料庫)
(2) each transaction is a list of items (一個項目列表,即: 消
費者一次購買活動中購買的商品)

Find:

all rules that correlate the presence of one set of items with
that of another set of items


E.g., 98% of people who purchase tires and auto accessories also
get automotive services done
Applications


  Maintenance Agreement (商店應該怎樣提高保養
用品的銷售?)
Home Electronics   (其他商品的庫存有什麼影響?)
14
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Association Rule Mining: A Road Map
 Frequent
pattern mining can be classified in various
way:
Based on the types of values handled in the rule (根據規則
中所處理的值類型)
 Based on the number of data dimensions involved in the rule
(根據規則中涉及的資料維度)
 Based on the levels of abstraction involved in the rule (根據
規則所涉及的抽象層次)

15
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Based on the types of values handled in the rule
 Boolean
associations

buys(x, “computer”) buys(x, “HP-printer”)

buys(x, “SQLServer”) ^ buys(x, “DMBook”) buys(x,
“DBMiner”)
 Quantitative

associations
age(x, “30..39”) ^ income(x, “42..48K”) buys(x, “high
resolution TV”)
16
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Based on the number of data dimensions involved in the rule
 Single
dimension associations

buys(x, “computer”) buys(x, “HP-printer”)

buys(x, “SQLServer”) ^ buys(x, “DMBook”) buys(x,
“DBMiner”)
 Multiple

dimensional associations
age(x, “30..39”) ^ income(x, “42..48K”) buys(x, “high
resolution TV”)
17
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Based on the levels of abstraction involved in the rule
 Multiple-level

Some association rule mining can find rules at differing levels
of abstraction.


Age(x, “30…39”)  buys(x, “laptop_computer”)
Age(x, “30…39”)  buys(x, “computer”)
 Single

analysis
level analysis
If the rules within a given set do not reference items or
attributes at different levels of abstraction.
18
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
19
 Mining Association Rules in Large Databases

Some methods for mining the simplest form of frequent
patterns – single-dimensional, single-level, Boolean frequent
itemsets (單維、單層、布林關聯規則的挖掘)


Apriori algorithm

How to generate strong association rules from frequent itemsets.

Several variations to the Apriori algorithm for improved efficiency and
scalability.
Presents methods for mining frequent itemsets that do not involve
the generation of “candidate” frequent itemsets.
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Mining Association Rules—An Example
Transaction ID
2000
1000
4000
5000
Items Bought
A,B,C
A,C
A,D
B,E,F
Min. support 50%
Min. confidence 50%
Frequent Itemset Support
{A}
75%
{B}
50%
{C}
50%
{A,C}
50%
For rule A  C:
support = support({A∪C}) = 50%
confidence = support({A∪C})/support({A}) = 66.6%
20
國立聯合大學 資訊管理學系

The Apriori principle:

Any subset of a frequent itemset must be frequent




資料探勘課程 (陳士杰)
if {beer, diaper, nuts} is frequent, so is {beer, diaper}
Every transaction having {beer, diaper, nuts} also
contains {beer, diaper}
Apriori pruning principle: If there is any itemset
which is infrequent, its superset should not be
generated/tested!
Method:


generate length (k+1) candidate itemsets from length k
frequent itemsets, and
test the candidates against DB
21
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
22
The Apriori Algorithm — Example
Database D
TID
100
200
300
400
itemset
C1
{1}
{2}
Scan D
{3}
{4}
{5}
Items
134
235
1235
25
sup.
2
3
3
1
3
C2 itemset sup
L2 itemset sup
{1 3}
{2 3}
{2 5}
{3 5}
2
2
3
2
C3 itemset
{2 3 5}
{1 2}
{1 3}
{1 5}
{2 3}
{2 5}
{3 5}
Scan D
1
2
1
2
3
2
L1 itemset sup.
{1}
{2}
{3}
{5}
2
3
3
3
C2 itemset
{1 2}
Scan D
L3 itemset sup
{2 3 5} 2
{1
{1
{2
{2
{3
3}
5}
3}
5}
5}
最小支持度︰2
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
使用Apiori性質由L2產生C3
1 . 連接:

C3=L2  L2 = {{A,C},{B,C},{B,E}{C,E}}  {{A,C},{B,C},{B,E}{C,E}}
= {{A,B,C},{A,C,E},{B,C,E}}
2. 使用Apriori性質剪枝: 頻繁項目集的所有子集必須是頻繁
的,對候選項C3,我們可以刪除其子集為非頻繁的選項:

{A,B,C}的2項子集是{A,B},{A,C},{B,C},其中{A,B}不是L2的元素,
所以刪除這個選項;

{A,C,E}的2項子集是{A,C},{A,E},{C,E},其中{A,E} 不是L2的元素,
所以刪除這個選項;

{B,C,E}的2項子集是{B,C},{B,E},{C,E},它的所有2-項子集都是L2
的元素,因此保留這個選項。
3. 這樣,剪枝後得到C3={B,C,E}
23
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
The Apriori Algorithm


Join Step: Ck is generated by joining Lk-1with itself
Prune Step: Any (k-1)-itemset that is not frequent cannot be a
subset of a frequent k-itemset

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;
24
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
25
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Example of Generating Candidates

L3={abc, abd, acd, ace, bcd}

Self-joining: L3*L3


abcd from abc and abd

acde from acd and ace
Pruning:


acde is removed because ade is not in L3
C4={abcd}
26
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
由頻繁項目集產生關聯規則

同時滿足最小支持度和最小置信度的才是強關聯
規則,從頻繁項目集產生的規則都滿足支持度要
求,而其置信度則可由一下公式計算︰
confidence (A  B)  P(B | A) 

support_co unt(A  B)
support_co unt(A)
每個關聯規則可由如下過程產生︰


對于每個頻繁項集l,產生l的所有非空子集;
對于每個非空子集s,如果
則輸出規則“s  (l  s ) ”
support_co unt(l)
 min_conf
support_co unt(s)
27
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Is Apriori Fast Enough? — Performance Bottlenecks

The bottleneck of Apriori: candidate generation

Huge candidate sets:



104 frequent 1-itemset will generate 107 candidate 2-itemsets
To discover a frequent pattern of size 100, e.g., {a1, a2, …, a100}, one needs
to generate 2100  1030 candidates.
Multiple scans of database:

Needs (n +1 ) scans, n is the length of the longest pattern
28
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Mining Frequent Patterns
Without Candidate Generation


Compress a large database into a compact, FrequentPattern tree (FP-tree) structure

highly condensed, but complete for frequent pattern mining

avoid costly database scans
Develop an efficient, FP-tree-based frequent pattern mining
method

A divide-and-conquer methodology: decompose mining tasks into
smaller ones

Avoid candidate generation: sub-database test only!
29
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
30
Construct FP-tree from a Transaction DB
TID
100
200
300
400
500
Items bought
(ordered) frequent items
{f, a, c, d, g, i, m, p}
{f, c, a, m, p}
{a, b, c, f, l, m, o}
{f, c, a, b, m}
{b, f, h, j, o}
{f, b}
{b, c, k, s, p}
{c, b, p}
{a, f, c, e, l, p, m, n}
{f, c, a, m, p}
Steps:
1. Scan DB once, find frequent
1-itemset (single item
pattern)
2. Order frequent items in
frequency descending order
3. Scan DB again, construct
FP-tree
min_support = 0.5
{}
Header Table
Item frequency head
f
4
c
4
a
3
b
3
m
3
p
3
f:4
c:3
c:1
b:1
a:3
b:1
p:1
m:2
b:1
p:2
m:1
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Benefits of the FP-tree Structure

Completeness:



never breaks a long pattern of any transaction
preserves complete information for frequent pattern mining
Compactness




reduce irrelevant information—infrequent items are gone
frequency descending ordering: more frequent items are more likely to
be shared
never be larger than the original database (if not count node-links and
counts)
Example: For Connect-4 DB, compression ratio could be over 100
31
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Mining Frequent Patterns Using FP-tree

General idea (divide-and-conquer)


Recursively grow frequent pattern path using the FP-tree
Method



For each item, construct its conditional pattern-base, and then its
conditional FP-tree
Repeat the process on each newly created conditional FP-tree
Until the resulting FP-tree is empty, or it contains only one path (single
path will generate all the combinations of its sub-paths, each of which is a
frequent pattern)
32
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Major Steps to Mine FP-tree
1)
Construct conditional pattern base for each node in the
FP-tree
2)
Construct conditional FP-tree from each conditional
pattern-base
3)
Recursively mine conditional FP-trees and grow frequent
patterns obtained so far

If the conditional FP-tree contains a single path, simply enumerate
all the patterns
33
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
34
Step 1: From FP-tree to Conditional Pattern Base



Starting at the frequent header table in the FP-tree
Traverse the FP-tree by following the link of each frequent item
Accumulate all of transformed prefix paths of that item to form a
conditional pattern base
Header Table
Item frequency head
f
4
c
4
a
3
b
3
m
3
p
3
{}
Conditional pattern bases
f:4
c:3
c:1
b:1
a:3
b:1
p:1
item
cond. pattern base
c
f:3
a
fc:3
b
fca:1, f:1, c:1
m:2
b:1
m
fca:2, fcab:1
p:2
m:1
p
fcam:2, cb:1
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
35
Properties of FP-tree for Conditional Pattern Base
Construction

Node-link property


For any frequent item ai, all the possible frequent patterns that
contain ai can be obtained by following ai's node-links, starting from
ai's head in the FP-tree header
Prefix path property

To calculate the frequent patterns for a node ai in a path P, only the
prefix sub-path of ai in P need to be accumulated, and its frequency
count should carry the same count as node ai.
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
36
Step 2: Construct Conditional FP-tree

For each pattern-base


Accumulate the count for each item in the base
Construct the FP-tree for the frequent items of the pattern base
Header Table
Item frequency head
f
4
c
4
a
3
b
3
m
3
p
3
{}
f:4
c:3
c:1
b:1
a:3
b:1
p:1
m-conditional pattern
base:
fca:2, fcab:1
{}

f:3 
m:2
b:1
c:3
p:2
m:1
a:3
All frequent patterns
concerning m
m,
fm, cm, am,
fcm, fam, cam,
fcam
m-conditional FP-tree
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
37
Mining Frequent Patterns by Creating Conditional PatternBases
Item
Conditional pattern-base
Conditional FP-tree
p
{(fcam:2), (cb:1)}
{(c:3)}|p
m
{(fca:2), (fcab:1)}
{(f:3, c:3, a:3)}|m
b
{(fca:1), (f:1), (c:1)}
Empty
a
{(fc:3)}
{(f:3, c:3)}|a
c
{(f:3)}
{(f:3)}|c
f
Empty
Empty
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
38
Step 3: Recursively mine the conditional FP-tree
{}
{}
Cond. pattern base of “am”: (fc:3)
f:3
c:3
f:3
am-conditional FP-tree
c:3
{}
Cond. pattern base of “cm”: (f:3)
a:3
f:3
m-conditional FP-tree
cm-conditional FP-tree
{}
Cond. pattern base of “cam”: (f:3)
f:3
cam-conditional FP-tree
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
39
Single FP-tree Path Generation

Suppose an FP-tree T has a single path P

The complete set of frequent pattern of T can be generated
by enumeration of all the combinations of the sub-paths of P
{}
f:3
c:3

a:3
m-conditional FP-tree
All frequent patterns
concerning m
m,
fm, cm, am,
fcm, fam, cam,
fcam
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Principles of Frequent Pattern Growth

Pattern growth property


Let  be a frequent itemset in DB, B be 's conditional pattern
base, and  be an itemset in B. Then    is a frequent itemset in
DB iff  is frequent in B.
“abcdef ” is a frequent pattern, if and only if

“abcde ” is a frequent pattern, and

“f ” is frequent in the set of transactions containing “abcde ”
40
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Why Is Frequent Pattern Growth Fast?

Our performance study shows

FP-growth is an order of magnitude faster than Apriori, and is also
faster than tree-projection

Reasoning

No candidate generation, no candidate test

Use compact data structure

Eliminate repeated database scan

Basic operation is counting and FP-tree building
41
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
42
FP-growth vs. Apriori: Scalability With the
Support Threshold
Data set T25I20D10K
100
D1 FP-grow th runtime
90
D1 Apriori runtime
80
Run time(sec.)
70
60
50
40
30
20
10
0
0
0.5
1
1.5
2
Support threshold(%)
2.5
3
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
43
 Multiple-Level Association Rules

Items often form hierarchy.

Items at the lower level are
expected to have lower
support.


這意味著挖掘底層數據項
之間的關聯規則必須定義
不同的支持度
在適當的等級挖掘出來的
數據項間的關聯規則可能
是非常有用的
All
desktop
printer
software
computer
laptop
financial
edu.
color
Computer
accessory
mouse
wrist
pad
b/w
IBM
Microsoft
HP
Sony
Logitech
Ergoway
TID
Items
{IBM D/C, Sony b/w}
T1
T2 {Ms. edu. Sw., Ms. fin. Sw.}
T3 {Logi. mouse, Ergoway wrist pad}
{IBM D/C, Ms. Fin. Sw.}
T4
{IBM D/C}
T5
國立聯合大學 資訊管理學系

資料探勘課程 (陳士杰)
通常,多層關聯規則的挖掘還是使用置信度-支
持度框架,可以採用Top-down策略

請注意: 概念分層中,一個節點的支持度肯定不小於該
節點的任何子節點的支持度

由概念層1開始向下,到較低的更特定的概念層,對每
個概念層的頻繁項目計算累加計數

每一層的關聯規則挖掘可以使用Apriori等多種方法

例如︰

先找高層的關聯規則︰computer -> printer [20%, 60%]

再找較低層的關聯規則︰laptop -> color printer [10%, 50%]
44
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Multi-level Association:
Uniform Support vs. Reduced Support

Uniform Support (一致支持度):

the same minimum support for all levels
優: One minimum support threshold. No need to examine itemsets containing
any item whose ancestors do not have minimum support (容易採用最佳化策
略).
 缺: Lower level items do not occur as frequently (最小支持度值設置困難). If
support threshold
 too high  miss low level associations
 too low  generate too many high level associations


Reduced Support (遞減支持度):

reduced minimum support at lower levels

There are 4 search strategies:




Level-by-level independent (逐層獨立)
Level-cross filtering by k-itemset (層交叉k項集過濾)
Level-cross filtering by single item (層交叉單項過濾)
Controlled level-cross filtering by single item (受控的層交叉單項過濾)
45
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
46
Uniform Support
Multi-level mining with uniform support
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
47
Reduced Support
Multi-level mining with reduced support
國立聯合大學 資訊管理學系

48
逐層獨立︰


資料探勘課程 (陳士杰)
完全的寬度搜索,沒有頻繁項目集的背景知識用於剪
枝
層交叉單項過濾︰

一個第i層的項目被考察 if and only if 它在第(i-1)層的
父節點是頻繁的
min_sup = 12%
min_sup = 3%
Computer
[support=10%]
Laptop
[未考察]
Desktop
[未考察]
(computer)( laptop computer, desktop computer)
國立聯合大學 資訊管理學系

資料探勘課程 (陳士杰)
49
層交叉k項目集過濾:
一個第i層的k項目集被考察if
and only if它在第(i-1)層的
對應父節點k-項集是頻繁的
Computer and printer [support = 7%]
min_sup = 5%
min_sup = 2%
Laptop computer
and b/w printer
[support = 1%]
Laptop computer
and color printer
[support = 2%]
Laptop computer
and b/w printer
[support = 1%]
Laptop computer
and color printer
[support = 2%]
(computer, printer)(( laptop computer, color printer),
(desktop computer, b/w printer) …)
國立聯合大學 資訊管理學系

資料探勘課程 (陳士杰)
搜索策略比較



逐層獨立策略條件鬆,可能導致底層考察出大量非頻
繁項目
層交叉k項集過濾策略限制太強,僅允許考察頻繁k-項
目集的子女
層交叉單項過濾策略是上述兩者的折中,但仍可能丟
失低層頻繁項目
50
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
51
受控的層交叉單項過濾策略


層交叉單項過濾策略的改進版本
設置一個層傳遞臨界值,用於向較低層傳遞相對頻繁的項
目。


即如果滿足層傳遞臨界值,則允許考察不滿足最小支持度臨界值
的項目的子女
用戶對進一步控制多概念層上的挖掘過程有了更多的靈活性,同
時減少無意義關聯的考察和產生
min_sup = 12%
level_passage_support =
8%
Computer [support=10%]
Laptop [support=6%]
min_sup = 3%
Desktop [support=4%]
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Multi-level Association: Redundancy Filtering



Some rules may be redundant due to “ancestor” relationships
between items.
Example

desktop computer => b/w printer [sup=8%, con=70%] (1)

IBM desktop computer => b/w printer [sup=2%, con=72%] (2)
We say the first rule is an ancestor of the second rule.

如果規則(2)中的項用它在概念分層中的“祖先”代替,能得到(1),
而且(1)的支持度和置信度都接近“期望”值,則(1)是冗餘的。
52
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
 Multi-Dimensional Association: Concepts

Single-dimensional rules:
buys(X, “milk”)  buys(X, “bread”)

Multi-dimensional rules:  2 dimensions or predicates (述語)

Inter-dimension association rules (沒有重覆出現的述語)
age(X,”19-25”)  occupation(X,“student”)  buys(X,“coke”)

hybrid-dimension association rules (有重覆出現的述語)
age(X,”19-25”)  buys(X, “popcorn”)  buys(X, “coke”)

在多維關聯規則挖掘中,我們搜索的不是頻繁項目集,
而是頻繁述語集。k-述語集 (frequent k-predicate set) 是
包含k個述語的集合。

例如︰{age, occupation, buys}是一個3-述語集
53
國立聯合大學 資訊管理學系

資料探勘課程 (陳士杰)
數據屬性可以分為分類屬性和量化屬性

Categorical Attributes


具有有限個不同值,值之間無序
Quantitative Attributes

數值類型的值,並且值之間有一個隱含的序
54
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Techniques for Mining MD Associations

挖掘多維關聯規則的技術可以根據量化屬性的處理分為
三種基本方法︰
1. Using static discretization of quantitative attributes (量化
屬性的靜態離散化)

使用預先定義的概念分層對量化屬性進行靜態地離散化
2. Quantitative association rules (量化關聯規則)

根據資料的分佈,將量化屬性離散化到“箱” (bins)
3. Distance-based association rules (基於距離的關聯規則)

考慮數據點之間的距離,動態地離散化量化屬性
55
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
56
Static Discretization of Quantitative Attributes

量化屬性使用預先定義的概念分層,在挖掘
前進行離散化

數值屬性的值用區間代替

如果任務相關資料存在資料庫中,則找出所
有頻繁的k-述語集將需要 k 或 k+1 次的Table
掃描
(age, income)

(age)
(income)
n-維方體的單元用於存放對應n-述語集的計
數或支持度,0-D方體用于存放任務相關數據
的事務總數
如果包含感興趣的維的資料立方體已經存在
並物化,挖掘將會很快,同時可以利用
Apriori性質︰頻繁述語集的每個子集也必須
是頻繁的
(buys)
(age,buys) (income,buys)
資料立方體技術非常適合挖掘多維關聯規則


()
(age,income,buys)
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
Quantitative Association Rules

量化關聯規則中,數值屬性將根據某種挖掘標準,進行動
態的離散化



例如︰最大化挖掘規則的置信度和緊湊性.
為了簡化量化關聯規則挖掘的討論,我們將聚焦于類似以
下形式的2-D quantitative association rules:
Aquan1  Aquan2  Acat
Example: (兩個量化屬性和一個分類屬性間的關聯)
age(X,”30-34”)  income(X,”24K - 48K”)
 buys(X,”high resolution TV”)
57
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)

找出這類2-維量化關聯規則的方法︰關聯規則聚類系統
(ARCS)

一種源於圖形處理的技術,該技術將量化屬性對映射到
滿足給定分類屬性條件的2-D閘格上,然後透過搜索閘格
點的聚類而產生關聯規則
58
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
ARCS (Association Rule Clustering System)
How does ARCS work?
1. Binning
2. Find frequent
predicateset
3. Clustering
4. Optimize
59
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
 ARCS過程中的步驟包括:
1. 分箱 (根據不同分箱方法創建一個2-D數組),本步驟的目的
在於減少量化屬性相對應的巨大的值個數,使得2-D閘格
的大小可控

等寬分箱

等深分箱

基於同質的分箱 (每個箱中Tuple一致分佈)
2. 找出頻繁述語集:

掃描分箱後形成的2-D數組,找出滿足最小支持度和置信度的頻
繁述語集
60
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
3. 關聯規則聚類
4. 將上一步得到的強關聯規則映射到2-D閘極格上,使用聚
類算法,掃描閘極格,搜索規則的矩形聚類
age( X ,34)  income( X , "31K ...40 K " )  buys( X , " high _ resolution _ TV " )
age( X ,35)  income( X , "31K ...40 K " )  buys( X , " high _ resolution _ TV " )
age( X ,34)  income( X , "41K ...50 K " )  buys( X , " high _ resolution _ TV " )
age( X ,35)  income( X , "41K ...50 K " )  buys( X , " high _ resolution _ TV " )
age( X ,34...35)  income( X , "31K ...50 K " )
 buys( X , " high _ resolution _ TV " )
61
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
ARCS的局限性

所挖掘的關聯規則左手邊只能是量化屬性

規則的左手邊只能有兩個量化屬性(2-D閘格的限制)

一種不基於閘格的,可以發現更一般關聯規則的技術,其
中任意個數的量化屬性和分類屬性可以出現下規則的兩端

等深分箱動態劃分

根據部分完全性的度量進行聚類
62
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
63
挖掘基於距離的關聯規則

因為未考慮資料點之間或區間的相對距離,分箱方法不是總能緊扣區
間資料的語義
Equi-width Equi-depth
DistancePrice($) (width $10)
(depth 2)
based
7
20
22
50
51
53




[0,10]
[11,20]
[21,30]
[31,40]
[41,50]
[51,60]
[7,20]
[22,50]
[51,53]
[7,7]
[20,22]
[50,53]
等寬劃分將很近的值分開,並創建沒有數據的區間
等深劃分將很遠的值放在一組
基於距離的關聯規則挖掘考慮屬性值的接近性,緊扣區間資料的語義,
並允許值的類似
基於距離的關聯規則挖掘的兩遍算法︰
1. 使用聚類找出區間或簇
2. 搜索頻繁的一起出現的簇組,得到基於距離的關聯規則
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
 Interestingness Measurements

Objective measures
Two popular measurements:


support; and

confidence
Subjective measures (Silberschatz & Tuzhilin, KDD95)

最終,只有用戶才能確定一個規則是否有趣的,而且這種判斷是
主觀的,因不同的用戶而異;通常認為一個規則(模式)是有趣
的,如果︰



它是出人意料的
可行動的(用戶可以使用該規則做某些事情)
挖掘了關聯規則後,哪些規則是用戶感興趣的?強關聯
規則是否就是有趣的?
64
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
65
Criticism to Support and Confidence

例1︰(Aggarwal & Yu, PODS98)

在10000個學生中

7500個買影片

6000個買遊戲片

4000個學生既買影片又買遊戲片
買遊戲片
買影片
不買影片
合計 (col.)

4000
2000
6000
不買遊戲片
3500
500
4000
合計 (row)
7500
2500
10000
上述數據可以得出
buys(X, “computer games”) => buys(X, “videos”) [40%, 60%]

但其實全部人中買影片的人數是75%,比60%多;事實上影片和遊戲是負相關的。

由此可見A => B的置信度有欺騙性,它只是給出A, B條件機率的估計,而不度量A,
B間蘊涵的實際強度。
國立聯合大學 資訊管理學系

資料探勘課程 (陳士杰)
We need a measure of dependent or correlated events
corrA, B
P( A B)

P( A) P( B)

P(B|A)/P(B) is also called the lift of rule A => B

若:


項目集A的出現獨立於項目集B的出現時,P(A∪B) = P(A) P(B),即corrA,B
=1,表明A與B無關;

corrA,B >1表明A與B正相關;

corrA,B <1表明A與B負相關
將相關性指標用於前面的例子,可得出影片和遊戲的相關性為︰
P({game, video})/(P({game})×P({video}))=0.4/(0.75×0.6)=0.89

結論︰影片和遊戲之間存在負相關
66
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
打籃球
不打籃球
合計
喝麥片粥
2000
1750
3750
不喝麥片粥
1000
250
1250
合計
3000
2000
5000

例︰(Aggarwal & Yu, PODS98)

在5000個學生中





3000個打籃球
3750個喝麥片粥
2000個學生既打籃球又喝麥片粥
然而,打籃球 => 喝麥片粥 [40%, 66.7%]是錯誤的,因為全部學生
中喝麥片粥的比率是75%,比打籃球學生的66.7%要高
打籃球 => 不喝麥片粥 [20%, 33.3%]這個規則遠比上面那個要精確,
儘管支持度和置信度都要低的多
67
國立聯合大學 資訊管理學系
資料探勘課程 (陳士杰)
 Summary

Association rule mining

probably the most significant contribution from the database
community in KDD

A large number of papers have been published

Many interesting issues have been explored

An interesting research direction

Association analysis in other types of data: spatial data, multimedia
data, time series data, etc.
68