Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran...

48
Naeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: [email protected] Data Mining Concepts & Techniques Lecture No. 05 Sequential Pattern Mining

Transcript of Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran...

Page 1: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Naeem Ahmed

Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro

Email: [email protected]

Data Mining Concepts & Techniques Lecture No. 05

Sequential Pattern Mining

Page 2: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Outline •  Data Mining: Sequential Pattern Mining

•  Basic concepts

•  BIDE+ algorithm

Acknowledgements: Introduction to Data Mining © Tan, Steinbach, Kumar

Page 3: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Sequence Data •  Certain order in which data (objects) are related

10 15 20 25 30 35

235

61

1

Timeline

Object A:

Object B:

Object C:

456

2 7812

16

178

Object Timestamp Events A 10 2, 3, 5 A 20 6, 1 A 23 1 B 11 4, 5, 6 B 17 2 B 21 7, 8, 1, 2 B 28 1, 6 C 14 1, 8, 7

Sequence Database:

Page 4: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Example: Sequence Data Sequence Database

Sequence Element (Transaction)

Event (Item)

Customer Purchase history of a given customer

A set of items bought by a customer at time t

Books, diary products, CDs, etc

Web Data Browsing activity of a particular Web visitor

A collection of files viewed by a Web visitor after a single mouse click

Home page, index page, contact info, etc

Event data History of events generated by a given sensor

Events triggered by a sensor at time t

Types of alarms generated by sensors

Genome sequences

DNA sequence of a particular species

An element of the DNA sequence

Bases A,T,G,C

Sequence

E1 E2

E1 E3 E2 E3

E4 E2

Element (Transaction)

Event (Item)

Page 5: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Sequence •  Formal Definition: A sequence is an ordered list of

elements (transactions) s = < e1 e2 e3 … >

–  Each element contains a collection of events (items) ei = {i1, i2, …, ik}

–  Each element is attributed to a specific time or location •  Length of a sequence, |s|, is given by the number

of elements of the sequence

•  A k-sequence is a sequence that contains k events (items)

Page 6: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Example: Sequence •  Web sequence:

< {Homepage} {Electronics} {Digital Cameras} {Canon Digital Camera} {Shopping Cart} {Order Confirmation} {Return to Shopping} >

•  Sequence of initiating events causing the nuclear accident at 3-mile Island: (http://stellar-one.com/nuclear/staff_reports/summary_SOE_the_initiating_event.htm)

< {clogged resin} {outlet valve closure} {loss of feedwater} {condenser polisher outlet valve shut} {booster pumps trip} {main waterpump trips} {main turbine trips} {reactor pressure increases}>

•  Sequence of books checked out at a library: <{Fellowship of the Ring} {The Two Towers} {Return of the King}>

Page 7: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Subsequence •  Formal Definition: A sequence <a1 a2 … an> is contained in

another sequence <b1 b2 … bm> (m ≥ n) if there exist integers i1 < i2 < … < in such that a1 ⊆ bi1 , a2 ⊆ bi1, …, an ⊆ bin

•  The support of a subsequence w is defined as the fraction of data sequences that contain w

•  A sequential pattern is a frequent subsequence (i.e., a subsequence whose support is ≥ minsup)

Data sequence Subsequence Contain?

< {2,4} {3,5,6} {8} > < {2} {3,5} > Yes

< {1,2} {3,4} > < {1} {2} > No

< {2,4} {2,4} {2,5} > < {2} {4} > Yes

Page 8: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Sequential Pattern Mining •  Pattern: an arrangement or sequence regularly

found in comparable objects or events

•  Given: –  a database of sequences –  a user-specified minimum support threshold, minsup

•  Task: –  Find all subsequences with support ≥ minsup

Page 9: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Sequential Pattern Mining: Challenge

•  Given a sequence: <{a b} {c d e} {f} {g h i}> –  Examples of subsequences:

<{a} {c d} {f} {g} >, < {c d e} >, < {b} {g} >, etc.

•  How many k-subsequences can be extracted from a given n-sequence?

12649:Answer

=⎟⎟⎠

⎞⎜⎜⎝

⎛=⎟⎟

⎞⎜⎜⎝

⎛kn

Page 10: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Sequential Pattern Mining: Challenge

•  A huge number of possible sequential patterns are hidden in databases

•  A mining algorithm should –  find the complete set of patterns, when possible,

satisfying the minimum support (frequency) threshold –  be highly efficient, scalable, involving only a small

number of database scans –  be able to incorporate various kinds of user-specific

constraints

Page 11: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Sequential Pattern Mining: Example

Minsup = 50% Examples of Frequent Subsequences: < {1,2} > s=60% < {2,3} > s=60% < {2,4}> s=80% < {3} {5}> s=80% < {1} {2} > s=80% < {2} {2} > s=60% < {1} {2,3} > s=60% < {2} {2,3} > s=60% < {1,2} {2,3} > s=60%

Object Timestamp EventsA 1 1,2,4A 2 2,3A 3 5B 1 1,2B 2 2,3,4C 1 1, 2C 2 2,3,4C 3 2,4,5D 1 2D 2 3, 4D 3 4, 5E 1 1, 3E 2 2, 4, 5

Page 12: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Extracting Sequential Patterns •  Given n events: i1, i2, i3, …, in

•  Candidate 1-subsequences: <{i1}>, <{i2}>, <{i3}>, …, <{in}>

•  Candidate 2-subsequences: <{i1, i2}>, <{i1, i3}>, …, <{i1} {i1}>, <{i1} {i2}>, …, <{in-1} {in}>

•  Candidate 3-subsequences: <{i1, i2 , i3}>, <{i1, i2 , i4}>, …, <{i1, i2} {i1}>, <{i1, i2} {i2}>, …, <{i1} {i1 , i2}>, <{i1} {i1 , i3}>, …, <{i1} {i1} {i1}>, <{i1} {i1} {i2}>, …

Page 13: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Sequential Pattern Mining: Algorithms

•  Concept introduction and an initial Apriori-like algorithm

–  Agrawal & Srikant. Mining sequential patterns, ICDE’95

•  Apriori-based method: GSP (Generalized Sequential Patterns: Srikant & Agrawal @ EDBT’96)

•  Pattern-growth methods: FreeSpan & PrefixSpan (Han et al.@KDD’00; Pei, et al.@ICDE’01)

•  Vertical format-based mining: SPADE (Zaki@Machine Leanining’00)

•  Constraint-based sequential pattern mining (SPIRIT: Garofalakis, Rastogi, Shim@VLDB’99; Pei, Han, Wang @ CIKM’02)

•  Mining closed sequential patterns: CloSpan (Yan, Han & Afshar @SDM’03)

Page 14: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Generalized Sequential Pattern (GSP) •  Step 1:

–  Make the first pass over the sequence database D to yield all the 1-element frequent sequences

•  Step 2:

Repeat until no new frequent sequences are found –  Candidate Generation:

•  Merge pairs of frequent subsequences found in the (k-1)th pass to generate candidate sequences that contain k items

–  Candidate Pruning: •  Prune candidate k-sequences that contain infrequent (k-1)-subsequences

–  Support Counting: •  Make a new pass over the sequence database D to find the support for these

candidate sequences

–  Candidate Elimination: •  Eliminate candidate k-sequences whose actual support is less than minsup

Page 15: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Candidate Generation •  Base case (k=2):

–  Merging two frequent 1-sequences <{i1}> and <{i2}> will produce two candidate 2-sequences: <{i1} {i2}> and <{i1 i2}>

•  General case (k>2): –  A frequent (k-1)-sequence w1 is merged with another frequent

(k-1)-sequence w2 to produce a candidate k-sequence if the subsequence obtained by removing the first event in w1 is the same as the subsequence obtained by removing the last event in w2

•  The resulting candidate after merging is given by the sequence w1 extended with the last event of w2.

–  If the last two events in w2 belong to the same element, then the last event in w2 becomes part of the last element in w1

–  Otherwise, the last event in w2 becomes a separate element appended to the end of w1

Page 16: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Candidate Generation Examples •  Merging the sequences

w1=<{1} {2 3} {4}> and w2 =<{2 3} {4 5}> will produce the candidate sequence < {1} {2 3} {4 5}> because the last two events in w2 (4 and 5) belong to the same element

•  Merging the sequences w1=<{1} {2 3} {4}> and w2 =<{2 3} {4} {5}> will produce the candidate sequence < {1} {2 3} {4} {5}> because the last two events in w2 (4 and 5) do not belong to the same element

•  We do not have to merge the sequences w1 =<{1} {2 6} {4}> and w2 =<{1} {2} {4 5}> to produce the candidate < {1} {2 6} {4 5}> because if the latter is a viable candidate, then it can be obtained by merging w1 with < {1} {2 6} {5}>

Page 17: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

GSP Example

< {1} {2} {3} >< {1} {2 5} >< {1} {5} {3} >< {2} {3} {4} >< {2 5} {3} >< {3} {4} {5} >< {5} {3 4} >

< {1} {2} {3} {4} >< {1} {2 5} {3} >< {1} {5} {3 4} >< {2} {3} {4} {5} >< {2 5} {3 4} > < {1} {2 5} {3} >

Frequent3-sequences

CandidateGeneration

CandidatePruning

Page 18: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Finding Length-1 Sequential Patterns •  Examine GSP using an example •  Initial candidates: all singleton sequences

–  <a>, <b>, <c>, <d>, <e>, <f>, <g>, <h> •  Scan database once, count support for

candidates

Cand Sup <a> 3 <b> 5 <c> 4 <d> 3 <e> 3 <f> 2 <g> 1 <h> 1

<a(bd)bcb(ade)> 50 <(be)(ce)d> 40

<(ah)(bf)abf> 30 <(bf)(ce)b(fg)> 20 <(bd)cb(ac)> 10

Sequence Seq. ID min_sup =2

Page 19: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

GSP: Generating Length-2 Candidates <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>

51 length-2 Candidates

Without Apriori property, 8*8+8*7/2=92 candidates

Apriori prunes 44.57% candidates

Page 20: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

THE GSP Mining Process

<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: 47 cand. 19 length-3 seq. pat. 20 cand. not in DB at all

4th scan: 8 cand. 6 length-4 seq. pat.

5th scan: 1 cand. 1 length-5 seq. pat.

Cand. cannot pass sup. threshold Cand. not in DB at all

<a(bd)bcb(ade)> 50

<(be)(ce)d> 40

<(ah)(bf)abf> 30

<(bf)(ce)b(fg)> 20

<(bd)cb(ac)> 10

Sequence Seq. ID

min_sup =2

Page 21: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Candidate Generate-and-test: Drawbacks

•  A huge set of candidate sequences generated

–  Especially 2-item candidate sequence

•  Multiple Scans of database needed

–  The length of each candidate grows by one at each database scan

•  Inefficient for mining long sequential patterns

–  A long pattern grow up from short patterns

–  The number of short patterns is exponential to the length of mined patterns

Page 22: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Timing Constraints (I)

{A B} {C} {D E}

<= ms

<= xg >ng

xg: max-gap

ng: min-gap

ms: maximum span

Data sequence Subsequence Contain?

< {2,4} {3,5,6} {4,7} {4,5} {8} > < {6} {5} > Yes

< {1} {2} {3} {4} {5}> < {1} {4} > No

< {1} {2,3} {3,4} {4,5}> < {2} {3} {5} > Yes

< {1,2} {3} {2,3} {3,4} {2,4} {4,5}> < {1,2} {5} > No

xg = 2, ng = 0, ms= 4

Page 23: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Mining Sequential Patterns with Timing Constraints

•  Approach 1: –  Mine sequential patterns without timing constraints –  Postprocess the discovered patterns

•  Approach 2: –  Modify GSP to directly prune candidates that violate

timing constraints –  Question:

•  Does Apriori principle still hold?

Page 24: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Apriori Principle for Sequence Data Object Timestamp Events

A 1 1,2,4A 2 2,3A 3 5B 1 1,2B 2 2,3,4C 1 1, 2C 2 2,3,4C 3 2,4,5D 1 2D 2 3, 4D 3 4, 5E 1 1, 3E 2 2, 4, 5

Suppose:

xg = 1 (max-gap)

ng = 0 (min-gap)

ms = 5 (maximum span)

minsup = 60%

<{2} {5}> support = 40%

but

<{2} {3} {5}> support = 60%

Problem exists because of max-gap constraint

No such problem if max-gap is infinite

Page 25: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Contiguous Subsequences •  s is a contiguous subsequence of

w = <e1>< e2>…< ek> if any of the following conditions hold:

1.  s is obtained from w by deleting an item from either e1 or ek 2.  s is obtained from w by deleting an item from any element ei that

contains more than 2 items 3.  s is a contiguous subsequence of s’ and s’ is a contiguous

subsequence of w (recursive definition)

•  Examples: s = < {1} {2} > –  is a contiguous subsequence of

< {1} {2 3}>, < {1 2} {2} {3}>, and < {3 4} {1 2} {2 3} {4} > –  is not a contiguous subsequence of

< {1} {3} {2}> and < {2} {1} {3} {2}>

Page 26: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Modified Candidate Pruning Step

•  Without maxgap constraint: –  A candidate k-sequence is pruned if at least one of its

(k-1)-subsequences is infrequent

•  With maxgap constraint: –  A candidate k-sequence is pruned if at least one of its

contiguous (k-1)-subsequences is infrequent

Page 27: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Timing Constraints (II)

{A B} {C} {D E}

<= ms

<= xg >ng <= ws

xg: max-gap

ng: min-gap

ws: window size

ms: maximum span

Data sequence Subsequence Contain? < {2,4} {3,5,6} {4,7} {4,6} {8} > < {3} {5} > No

< {1} {2} {3} {4} {5}> < {1,2} {3} > Yes

< {1,2} {2,3} {3,4} {4,5}> < {1,2} {3,4} > Yes

xg = 2, ng = 0, ws = 1, ms= 5

Page 28: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Modified Support Counting Step •  Given a candidate pattern: <{a, c}>

–  Any data sequences that contain

<… {a c} … >, <… {a} … {c}…> ( where time({c}) – time({a}) ≤ ws) <…{c} … {a} …> (where time({a}) – time({c}) ≤ ws)

will contribute to the support count of candidate pattern

Page 29: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Other Formulation •  In some domains, we may have only one very long

time series –  Example:

•  monitoring network traffic events for attacks •  monitoring telecommunication alarm signals

•  Goal is to find frequent sequences of events in the time series –  This problem is also known as frequent episode mining

Page 30: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE+ Algorithm •  BIDE (BI-Directional Extension):

–  Saves space –  Speed up –  Finds frequent closed sequences

•  Closed itemset: An itemset is closed if none of its immediate supersets has the same support as the itemset

Page 31: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Frequent Closed Sequences

•  Frequent sequences –  A:4, AA:2, AB:4, ABB:2, ABC:4, AC:4, B:4, BB:2,BC:4,

C:4, CA:3, CAB:2, CABC:2, CAC:2, CB:3, CBC:2,CC:2 •  Frequent closed sequences

–  AA:2, ABB:2, ABC:4, CA:3, CABC:2,CB:3

Sequence identifier Sequence 1 CAABC 2 ABCB 3 CABC 4 ABBCA

Page 32: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

Frequent Closed Sequences

Page 33: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: space usage •  Most of the frequent closed pattern mining

algorithms need to maintain the set of already mined frequent closed patterns (or just candidates) in memory –  subpattern checking –  super-pattern checking

Page 34: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Mining Frequent Closed Sequences

•  Compact •  Efficient •  Costly in both runtime and space usage

–  BI-Directional Extension •  mining frequent closed sequences without candidate

maintenance

Page 35: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Closure checking scheme

•  if an n-sequence, S=e1e2. . . en, is non-closed

–  e’ is a forward-extension event •  S‘ = e1e2 . . . ene’ and supSDB(S’) = supSDB(S)

–  e’ is a backward-extension event •  ∃i (1 ≤ i < n), S ‘= e1e2 . . . eie’ei+1 . . .en and supSDB(S’) = supSDB(S)

•  S‘ = e’e1e2 . . . en and supSDB(S’) = supSDB(S)

Page 36: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Theorem, Lemma •  Theorem: BI-Directional Extension closure

checking

–  If there exists no forward-extension event nor backward extension event w.r.t. a prefix sequence Sp, Sp must be a closed sequence; otherwise, Sp must be non-closed

•  Lemma: Forward-extension event checking

–  For a pre-fix sequence Sp, its complete set of forward-extension events is equivalent to the set of its locally frequent items whose supports are equal to SUPSDB(Sp)

Page 37: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Definitions •  Projected sequence of a prefix sequence

–  the projected sequence of prefix sequence AB in sequence ABBCA is BCA

•  Projected database of a prefix sequence –  the projected database of prefix sequence AB in our

running example is {C, CB, C, BCA}

Sequence identifier Sequence 1 CAABC 2 ABCB 3 CABC 4 ABBCA

Page 38: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Lemma •  Backward-extension event checking

–  First, we assume Sp=AC:4, it is easy to find that item B appears in each of the 2nd maximum periods of Sp. As a result AC:4 is not closed.

–  let Sp=ABC:4, we cannot find any backward-extension item for it. Also there is no forward-extension item for it, therefore ABC:4 is a frequent closed sequence

Sequence identifier Sequence 1 CAABC 2 ABCB 3 CABC 4 ABBCA

Page 39: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Definition •  First instance of a prefix sequence

–  the first instance of the prefix sequence AB in sequence CAABC is CAAB

•  Last instance of a prefix sequence –  the subsequence from the beginning of S to the last

appearance of item ei in S •  the last instance of the prefix sequence AB in sequence ABBCA is ABB

•  Given an input sequence S which contains a prefix i-sequence e1e2 . . . ei –  The i-th last-in-last appearance w.r.t. a pre-fix sequence

•  it is the last appearance of ei in the last instance of the prefix Sp in S –  S=CAABC and Sp=AB, the 1st last-in-last appearance w.r.t. prefix Sp in

S is the second A in S

Page 40: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Definition •  Given an input sequence S which contains a prefix i-

sequence e1e2 . . . ei

–  The i-th maximum period of a prefix sequence •  if 1 < i ≤ n, it is the piece of sequence between the end of the

first instance of prefix e1e2 . . . ei−1 in S and the i-th last-in-last appearance w.r.t. prefix Sp

•  if i = 1, it is the piece of sequence in S locating before the 1st last-in-last appearance w.r.t. prefix Sp

–  S=ABCB and the prefix sequence Sp=AB »  2nd maximum period of prefix Sp in S is BC, »  1st maximum period of prefix Sp in S is φ

Page 41: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Example •  S=CAABCBC and Sp=AB

–  First instance of a prefix sequence •  CAAB

–  Last instance of a prefix sequence •  CAABCB

–  The i-th last-in-last appearance w.r.t. a pre-fix sequence

•  1st ---- 2nd A •  2nd ---- 2nd B

–  The i-th maximum period of a prefix sequence •  1st ---- CA •  2nd ---- ABC

Page 42: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Definition •  Given an input sequence S which contains a prefix

i-sequence e1e2 . . . ei –  The i-th last-in-first appearance w.r.t. a prefix

sequence •  it is the last appearance of ei in the first instance of the prefix Sp

in S –  S=CAABC and Sp=CA

»  2nd last-in-first appearance w.r.t. prefix Sp in S is the first A in S

Page 43: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Definition •  Given an input sequence S which contains a prefix

i-sequence e1e2 . . . ei –  The i-th semi-maximum period of a prefix sequence

•  if 1 < i ≤ n, it is the piece of sequence between the end of the first instance of prefix e1e2 . . . ei−1 in S and the i-th last-in-first appearance w.r.t. prefix Sp

•  if i = 1, it is the piece of sequence in S locating before the 1st last-in-first appearance w.r.t. pre-fix Sp

–  S=ABCB and the prefix sequence Sp=AC »  2nd semi-maximum period of prefix AC in S is B »  1st semi-maximum period of prefix AC in S is φ

Page 44: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Theorem •  BackScan search space pruning

–  Let the pre-fix sequence be an n-sequence, Sp=e1e2 . . . en. If ∃i (1 ≤ i ≤ n) and there exists an item e’ which appears in each of the i-th semi-maximum periods of the prefix Sp in SDB, we can safely stop growing prefix Sp

Sequence identifier Sequence

1 CAABC 2 ABCB 3 CABC 4 ABBCA

Page 45: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: ScanSkip •  The ScanSkip optimization technique

–  closure checking scheme needs to scan backward a set of maximum-periods w.r.t. a certain prefix

•  Sp=ABC : 4 –  3rd maximum periods is {φ, φ, φ, B} => skip last three –  2nd maximum periods is {A, φ, φ, B} => skip last two –  1st maximum periods is {CA, φ, C, φ} => skip last two

Sequence identifier Sequence 1 CAABC 2 ABCB 3 CABC 4 ABBCA

Page 46: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE Algorithm •  scans the database once to find the frequent 1-

sequences –  projected database for each frequent 1- sequence

•  BackScan pruning method •  backward-extension-item & forward-extension-item

–  output Sp as a frequent closed sequence •  grow Sp to get a new prefix

–  projected database for the new pre-fix •  ※BackScan and backward extension use the

ScanSkip to speed up the mining process

Page 47: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining

BIDE: Frequent Closed Sequences

Page 48: Data Mining Concepts & Techniques fileNaeem Ahmed Department of Software Engineering Mehran Univeristy of Engineering and Technology Jamshoro Email: naeemmahoto@gmail.com Data Mining