

















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















November
8,^
2007
CS^
434
2007
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
What
kinds
of
are
sensitive
to
this
new
drug?
Can
we
automatically
classify
web
documents?
-^
Broad
applications
-^
Basket
data
analysis,
cross
‐marketing,
catalog
design,
sale
campaign
analysis
-^
Web
log
(click
stream)
analysis
l^
i
November
8,^
2007
CS^
434
2007
-^
sequence
analysis
Itemset^ –
A
collection
of
one
or
more
items
-^
Example: {Milk Bread Diaper}Example:
{Milk
,^ Bread
,^ Diaper}
-^
k‐itemset^ •
An
itemset that
contains
k^
items
Support count (
σ )
TID
Items
1
Bread, Milk
2
Bread Diaper Beer Eggs
Support
count
( σ
-^
Frequency
of
occurrence
of
an
itemset
-^
E.g.
σ
({Milk,
Bread,Diaper})
=^
2
Support
2
Bread, Diaper, Beer, Eggs
3
Milk, Diaper, Beer, Coke
4
Bread, Milk, Diaper, Beer
5
Bread Milk Diaper Coke
Support^ –
Fraction
of
transactions
that
contain
an
itemset
-^
E g
s({Milk Bread Diaper}) = 2/
5
Bread, Milk, Diaper, Coke
E.g.
s({Milk
,^ Bread
,^ Diaper})
2/
Frequent
Itemset
-^
An
itemset whose
support
is
greater
than
or equal to a
minsup
threshold
or
equal
to
a^
minsup
threshold
z^
Association
Rule
-^
An
implication
expression
of
the
form
X^ →
Y where X and Y are
itemsets
TID
Items
1
Bread, Milk
X^ →
Y,
where
X
and
Y^
are
itemsets
-^
Example:{Milk,
Diaper}
→
{Beer}
2
Bread, Diaper, Beer, Eggs
3
Milk, Diaper, Beer, Coke
4
Bread, Milk, Diaper, Beer
Example:
z^
Rule
Evaluation
Metrics
-^
Support
(s)
^
F^
ti^
f t
ti^
th t
t i
5
Bread, Milk, Diaper, Coke
Example:
σ
^
Fraction
of
transactions
th
at^
contain
both
X^
and
Y:
P(X
^^
Y)
-^
Confidence
(c)
^
Measures how often items in Y
σ
^
Measures
how
often
items
in
Y
appear
in
transactions
that
contain
X^
:^ P(Y|X)
σ
November
8,^
2007
5
CS^
434
2007
November
8,^
2007
CS^
434
2007
Example
of
Rules:
{Milk Diaper}
{Beer} (s=0 4 c=0 67)
TID
Items
1
B^
d Milk
{Milk
,Diaper}
{Beer}
(s=
c=
{Milk,Beer}
{Diaper}
(s=0.4,
c=1.0)
{Diaper,Beer}
{Milk}
(s=0.4,
c=0.67)
{Beer}
{Milk,
Diaper}
(s
c=0.67)
1
Bread, Milk
2
Bread, Diaper, Beer, Eggs
3
Milk, Diaper, Beer, Coke
{ eer}
{Milk,
iaper} (s 0.4, c 0.67)
{Diaper}
{Milk,Beer}
(s=0.4,
c=0.5)
{Milk}
{Diaper,Beer}
(s=0.4,
c=0.5)
4
Bread, Milk, Diaper, Beer
5
Bread, Milk, Diaper, Coke
Observations:Observations: • All
the
above
rules
are
binary
partitions
of
the
same
itemset:
{Milk,
Diaper,
Beer}
originating
from
the
same
itemset have
identical
support
but
can
have
different
confidence
Th
d^
l^
h^
d^
fid
i
we
may
d
ecouple
the
support
and
confidence
requirements
can
first
find
all
frequent
itemsets that
satisfy
the
support
requirement
null
A^
B^
C^
D^
E
AB
AC
AD
AE
BC
BD
BE
CD
CE
DE
AB
AC
AD
AE
BC
BD
BE
CD
CE
DE
ABC
ABD
ABE
ACD
ACE
ADE
BCD
BCE
BDE
CDE
ABCD
ABCE
ABDE
ACDE
BCDE
Given
d
items,
there
are
d 2 possible
candidate
ABCDE
p itemsets
November
8,^
2007
CS^
434
2007
Each
itemset in
the
lattice
is
a
candidate frequent
itemset
Count
the
support
of
each
candidate
by
scanning
the
database
Transactions
TID
Items
1
Bread, Milk
2
B^
d Di
B^
E
Transactions
2
Bread, Diaper, Beer, Eggs
3
Milk, Diaper, Beer, Coke
4
Bread, Milk, Diaper, Beer
5
Bread, Milk, Diaper, Coke
Match
each
transaction
against
every
candidate
C
l^
i^
O(NM
)^
E^
i^
i^
M
d 2 !!!
5
Bread, Milk, Diaper, Coke
C
omplexity
~
O(
NM
w)
=>
E
xpensive
since
M
=
2
d^
!!!
-^
Apriori
principle:
If^
an
itemset
is
frequent,
then
all
of
its
subsets
must
also
be
frequent
f^ {b
di
}^ i
f
i^
{b
di
If^
{b
eer,
di
aper,
nuts}
is
frequent,
so
is
{b
eer,
di
aper}
i.e.,
every
transaction
having
{beer,
diaper,
nuts}
also
contains
{beer,
diaper}
-^
Apriori
principle
holds
due
to
the
following
property
of
the
t
support
measure:
Support
of
an
itemset
never
exceeds
the
support
of
its
subsets
This
is
known
as
the
anti
‐monotone property
of
support
November
8,^
2007
CS^
434
2007
Illustrating
Apriori
Principle
g^
p
p
Found
to
be
InfrequentInfrequent
Pruned supersets
November
8,^
2007
CS^
434
2007
Let
k=
Generate
frequent
itemsets
of
length
1
Repeat
until
no
new
frequent
itemsets
are
identified
-^
-^
-^
-^
November
8,^
2007
CS^
434
2007
The
Apriori
Algorithm—An
Example
Database TDB
C
L
1
Tid
Items
Itemset
sup
{A}
2
{B}
3
Itemset
sup
{A}
2
Sup
min
= 2 st 1 scan
C
1
1
Tid
Items
10
A, C, D
20
B, C, E
30
A B C E
{B}
3
{C}
3
{D}
1
{E}
3
{B}
3
{C}
3
{E}
3
L
C
2
C
2
nd 2
30
A, B, C, E
40
B, E
{E}
3
Itemset
Itemset
sup
{A, B}
1
It^
t
L^2
nd 2
scan
{A, B}{A, C}{A, E}{^
C}
{^
,^
} {A, C}
2
{A, E}
1
{B, C}
2
Itemset
sup
{A, C}
2
{B, C}
2
{B E}
3
{B, C}{B, E}{C, E}
{B, E}
3
{C, E}
2
{B, E}
3
{C, E}
2
C
3
L
3
rd 3 scan
Itemset {B, C, E}
Itemset
sup
{B, C, E}
2
November
8,^
2007
CS^
434
2007
How
to
generate
candidates?
-^
Step
1:
self
‐joining
L^ k
-^
Step
2:
pruning
How
to
count
supports
of
candidates?
Example of Candidate generation
-^
Example
of
Candidate
‐generation
-^
L
= {
abc,
abd,
acd,
ace,
bcd
}
-^
Self
‐joining:
L^3
*L
3
-^
abcd
from
abc
and
abd
-^
acde
from
acd
and
ace
-^
Pruning:
-^
acde
is
removed
because
ade
is
not
in
L^3
-^
C^4
={
abcd
}
November
8,^
2007
CS^
434
2007
-^
Suppose
the
items
in
Lk
‐^1
are
listed
in
an
order
-^
Step
1:
self
‐joining
L
k‐^1
insert
into
C^ k
l^
i^
i^
i^
i
select
p.item
,^1 p.item
,^2 …,
p.item
k‐^1
,^ q.item
k‐^1
from
L^ k
‐^1
p,
L^ k
q‐ 1
where
p.item
=q.item 1
,^1 …,
p.item
k‐^2
=q.item
k‐^2
,^ p.item
k‐^1
<^ q.item
k‐^1
-^
Step
2:
pruning
forall
itemsets
c^
in
C
do k^
forall
(k
1)
subsets s of c
do
forall
(k
‐1)
‐subsets
s^
of
c^
do
if^
(s
is
not
in
L
k‐^1
)^ then
delete
c
from
C
k
November
8,^
2007
CS^
434
2007