This preview shows page 1. Sign up to view the full content.
Unformatted text preview: PrefixSpan: Mining Sequential Patterns Efficiently by Prefix-Projected Pattern Growth
Jian Pei Jiawei Han Behzad Mortazavi-Asl Helen Pinto Intelligent Database Systems Research Lab. School of Computing Science, Simon Fraser University Burnaby, B.C., Canada V5A 1S6 E-mail: peijian, han, mortazav, hlpinto @cs.sfu.ca Qiming Chen Umeshwar Dayal Mei-Chun Hsu Hewlett-Packard Labs. Palo Alto, California 94303-0969 U.S.A. E-mail: qchen, dayal, mchsu @hpl.hp.com Abstract
Sequential pattern mining is an important data mining problem with broad applications. It is challenging since one may need to examine a combinatorially explosive number of possible subsequence patterns. Most of the previously developed sequential pattern mining methods follow the methodology of which may substantially reduce the number of combinations to be examined. However, still encounters problems when a sequence database is large and/or when sequential patterns to be mined are numerous and/or long. In this paper, we propose a novel sequential pattern mining method, called PrefixSpan (i.e., Prefix-projected Sequential pattern mining), which explores prefixprojection in sequential pattern mining. PrefixSpan mines the complete set of patterns but greatly reduces the efforts of candidate subsequence generation. Moreover, prefix-projection substantially reduces the size of projected databases and leads to efficient processing. Our performance study shows that PrefixSpan outperforms both the -based GSP algorithm and another recently proposed method, FreeSpan, in mining large sequence databases. 1 Introduction Sequential pattern mining, which discovers frequent subsequences as patterns in a sequence database, is an important data mining problem with broad applications, including the analyses of customer purchase behavior, Web access patterns, scientific experiments, disease treatments, natural disasters, DNA sequences, and so on.
The work was supported in part by the Natural Sciences and Engineering Research Council of Canada (grant NSERC-A3723), the Networks of Centres of Excellence of Canada (grant NCE/IRIS-3), and the Hewlett-Packard Lab, U.S.A. The sequential pattern mining problem was first introduced by Agrawal and Srikant in : Given a set of sequences, where each sequence consists of a list of elements and each element consists of a set of items, and given a user-specified min support threshold, sequential pattern mining is to find all of the frequent subsequences, i.e., the subsequences whose occurrence frequency in the set of sequences is no less than min support. Many studies have contributed to the efficient mining of sequential patterns or other frequent patterns in timerelated data, e.g., [2, 11, 9, 10, 3, 8, 5, 4]. Almost all of the previously proposed methods for mining sequential patterns and other time-related frequent patterns are -like, i.e., based on the property proposed in association mining , which states the fact that any super-pattern of a nonfrequent pattern cannot be frequent. Based on this heuristic, a typical -like method such as GSP  adopts a multiple-pass, candidategeneration-and-test approach in sequential pattern mining. This is outlined as follows. The first scan finds all of the frequent items which form the set of single item frequent sequences. Each subsequent pass starts with a seed set of sequential patterns, which is the set of sequential patterns found in the previous pass. This seed set is used to generate new potential patterns, called candidate sequences. Each candidate sequence contains one more item than a seed sequential pattern, where each element in the pattern may contain one or multiple items. The number of items in a sequence is called the length of the sequence. So, all the candidate sequences in a pass will have the same length. The scan of the database in one pass finds the support for each candidate sequence. All of the candidates whose support in the database is no less than min support form the set of the newly found sequential patterns. This set then becomes the seed set for the next pass. The algorithm terminates when no new sequential pattern is found in a pass, or no candidate sequence can be generated. Similar to the analysis of frequent pattern min- ing method in , one can observe that the -like sequential pattern mining method, though reduces search space, bears three nontrivial, inherent costs which are independent of detailed implementation techniques. Potentially huge set of candidate sequences. Since the set of candidate sequences includes all the possible permutations of the elements and repetition of items in a sequence, the -based method may generate a really large set of candidate sequences even for a moderate seed set. For example, if there frequent sequences of length-1, such as , are , ..., , an -like algorithm will generate candidate sequences, where the first term is derived from the set , , ..., , , , ..., , and the second term is derived from the set , , ..., . Multiple scans of databases. Since the length of each candidate sequence grows by one at each database scan, to find a sequential pattern , the -based method must scan the database at least 15 times. Difficulties at mining long sequential patterns. A long sequential pattern must grow from a combination of short ones, but the number of such candidate sequences is exponential to the length of the sequential patterns to be mined. For example, suppose there is only a single sequence of length 100, , in the database, and the min support threshold is 1 (i.e., every occurring pattern is frequent), to (re-)derive this length-100 sequential pattern, the -based method has to generate 100 length-1 candidate sequences, length-2 candidate sequences, length-3 candidate sequences1 , . . . . Obviously, the total number of candidate sequences to be generated is greater than .
q r i p g h0 X V V 6f T S ec b d A 0 YUS V X 6VW T & & % $Q !PI # 0 1 Notice that does cut a substantial amount of search space. Otherwise, the number of length-3 candidate sequences would have been . In many applications, it is not unusual that one may encounter a large number of sequential patterns and long sequences, such as in DNA analysis or stock sequence analysis. Therefore, it is important to re-examine the sequential pattern mining problem to explore more efficient and scalable methods. Based on our analysis, both the thrust and the bottleneck of an -based sequential pattern mining method come from its step-wise candidate sequence generation and test. Can we develop a method which may absorb the spirit of but avoid or substantially reduce the expensive candidate generation and test? With this motivation, we first examined whether the FP-tree structure , recently proposed in frequent pattern mining, can be used for mining sequential patterns. The FP-tree structure explores maximal sharing of common prefix paths in the tree construction by reordering the items in transactions. However, the items (or subsequences) containing different orderings cannot be reordered or collapsed in sequential pattern mining. Thus the FP-tree structures so generated will be huge and cannot benefit mining. As a subsequent study, we developed a sequential mining method , called FreeSpan (i.e., Frequent patternprojected Sequential pattern mining). Its general idea is to use frequent items to recursively project sequence databases into a set of smaller projected databases and grow subsequence fragments in each projected database. This process partitions both the data and the set of frequent patterns to be tested, and confines each test being conducted to the corresponding smaller projected database. Our performance study shows that FreeSpan mines the complete set of patterns and is efficient and runs considerably faster than the -based GSP algorithm. However, since a subsequence may be generated by any substring combination in a sequence, projection in FreeSpan has to keep the whole sequence in the original database without length reduction. Moreover, since the growth of a subsequence is explored at any split point in a candidate sequence, it is costly. In this study, we develop a novel sequential pattern mining method, called PrefixSpan (i.e., Prefix-projected Sequential pattern mining). Its general idea is to examine only the prefix subsequences and project only their corresponding postfix subsequences into projected databases. In each projected database, sequential patterns are grown by exploring only local frequent patterns. To further improve mining efficiency, two kinds of database projections are explored: level-by-level projection and bi-level projection. Moreover, a main-memory-based pseudo-projection technique is developed for saving the cost of projection and speeding up processing when the projected (sub)-database and its associated psuedo-projection processing structure can fit in main memory. Our performance study shows that bi-level projection has better performance when the database is large, and pseudo-projection speeds up the processing substantially when the projected databases can fit in memory. PrefixSpan mines the complete set of patterns and is efficient and runs considerably faster than both -based GSP algorithm and FreeSpan. The remaining of the paper is organized as follows. In Section 2, we define the sequential pattern mining problem and illustrate the ideas of our previously developed pattern growth method FreeSpan. The PrefixSpan method is developed in Section 3. The experimental and performance results are presented in Section 4. In Section 5, we discuss its relationships with related works. We summarize our study and point out some research issues in Section 6. V 6V e e T d (T 5 1 3 3 2 1 ('4 9 (& 8( & & 7 6' V V T V V T V V T V V T V V QQe6I6E66)6T F 9 D C 7 9 D C 7 9 D C 7 9 D C 7 9 D C 7 G664@E664@E664@E664@E664@4B 0 6$' & % & (& ) ' 9A @7 )4 8( 9 7 $ ('6$ # $"! !4 H H H wv wv t 6y xus a 1 ` $ 5 3 1 2 RE Example 2 (FreeSpan) Given the database and min support in Example 1, FreeSpan first scans , collects the support for each item, and finds the set of frequent items. Frequent items are listed in support descending order (in the form of ) as below, U
D C 0 f list According to f list, the complete set of sequential patterns in can be divided into 6 disjoint subsets: (1) the ones containing only item , (2) the ones containing item but containing no items after in f list, (3) the ones containing item but no items after in f list, and so on, and finally, (6) the ones containing item . The subsets of sequential patterns can be mined by constructing projected databases. Infrequent items, such as in this example, are removed from construction of projected databases. The mining process is detailed as follows. Finding sequential patterns containing only item . By scanning sequence database once, the only two sequential patterns containing only item , and , are found. Finding sequential patterns containing item but no item after in f list. This can be achieved by constructing the -projected database. For a sequence in containing item , a subsequence is derived by removing from all items afin f list. is inserted into -projected ter -projected database contains four database. Thus, sequences: , , and . By scanning the projected database once more, all sequential patterns containing item but no item after in f list are found. They are , , , . Finding other subsets of sequential patterns. Other subsets of sequential patterns can be found similarly, by constructing corresponding projected databases and mining them recursively.
F C 9 C 7 )64@( C C E F C QB C 46 C 9 C 7 6648( 4 C 4 Example 1 (Running example) Let our running database be sequence database given in Table 1 and min support = 2. The set of items in the database is .
y Table 1. A sequence database A sequence has five elements: , , , and , where items and appear more than once respectively in different elements. It is also a sequence since there are 9 instances appearing in that sequence. Item happens three times in this sequence, so it contributes 3 to the length of the sequence. However, the whole sequence contributes only one to the support of . Also, sequence is a subsequence of . Since both sequences 10
9 4@7 3 D 9 Note that -, -, . . . , -projected databases are constructed simultaneously during one scan of the original
B F D B F C B A 6C4 C C C E C E y )64@ 9 C 7 F C B A F C B T A C A y 9 U 9 D C7 66@ D C D 666)9 87 y gw E69 @E64@69 C D U7 9 C 7 7 ( y y w 9 @E66@7 4@( 7 9 D C D 9 U 7 w D7 U 9 D 7 9 D C 7 @64@6E64@ Sequence id 10 20 30 40 Sequence T T y 1 w H1 y e c a Y Y X db`C D 1 2 RQ C 1 2 RQ 8 w 1 R2 e D T C In this section, we first define the problem of sequential pattern mining, and then illustrate our recently proposed method, FreeSpan, using an example. Let be a set of all items. An itemset is a subset of items. A sequence is an ordered list of , where itemsets. A sequence is denoted by is an itemset, i.e., for . is also called an element of the sequence, and denoted as , where is an item, i.e., for . For brevity, the brackets are omitted if an element has only one item. That is, element is written as . An item can occur at most once in an element of a sequence, but can occur multiple times in different elements of a sequence. The number of instances of items in a sequence is called the length of the sequence. A sequence with length is called an -sequence. A sequence is called a subsequence of another sequence and a super sequence of , denoted as , if there exist integers such that , , ..., . A sequence database is a set of tuples , where is a sequence id and is a sequence. A tuple is said to contain a sequence , if is a subsequence of , i.e., . The support of a sequence in a sequence database is the number of tuples in the database containing , i.e., . It can be denoted as if the sequence database is clear from the context. Given a positive integer as the support threshold, a sequence is called a (frequent) sequential pattern in sequence database if the sequence is contained by at least tuples in the database, i.e., . A sequential pattern with length is called an -pattern.
$ s t 9 A e c a Y Y X vu!@7 f $ db`C s T A s 9 A7 e c a Y Y X !@drC` h qG'7 (9 G @7 h 'B F 9 E A p T 3 U U 1 1 hi0 9 'gdb`C A7 f e c a Y Y X A T A E WVA A A @ U '1U @ U T 1 S C R C QC I I I P 8 ! ! "H D E GFA G ! A D ) C (Q 0 D C C $CB4 0 A $ 8 (R& 5 '7 9")0&9764 & $ ! %#" @ $ & 3 1 "2&
9 & @7 Problem Statement. Given a sequence database and a min support threshold, the problem of sequential pattern mining is to find the complete set of sequential patterns in the database. In Section 1, we outlined the -like method GSP . To improve the performance of sequential pattern mining, a FreeSpan algorithm is developed in our recent study . Its major ideas are illustrated in the following example. 6648G D 9 C 7 0 2 Problem Definition and FreeSpan and 30 contain subsequence pattern of length 3 (i.e., -pattern). , is a sequential F 1 y 1 w x1 U D C QB 1 1 1 9 y 9 @64@6E64@ D7 U 9 D 7 9 D C 7 y 4 D7 U 9 D 7 9 D C 7 8R64@E664@ y 9 87 D 9 U '7 y D7 U 9 D 7 9 D C 7 8R64@E664@ F H H H @ B 1 1 1 T 9 D 9 D C 64@7 E64@7 0 1 2& For example, , , and are prefixes of sequence , but neither nor is considered as a prefix. is the postfix of the same sequence w.r.t. prefix , is the postfix w.r.t. prefix , and is the postfix w.r.t. prefix . Example 3 (PrefixSpan) For the same sequence in Table 1 with , sequential database patterns in can be mined by a prefix-projection method in the following steps. Step 1: Find length-1 sequential patterns. Scan once to find all frequent items in sequences. Each of these frequent items is a length-1 sequential pattern. They are , , , , , and , where represents the pattern and its associated support count. Step 2: Divide search space. The complete set of sequential patterns can be partitioned into the following six subsets according to the six prefixes: (1) the ones having prefix ; . . . ; and (6) the ones having prefix . Step 3: Find subsets of sequential patterns. The subsets of sequential patterns can be mined by constructing corresponding projected databases and mine each recursively. The projected databases as well as sequential patterns found in them are listed in Table 2, while the mining process is explained as follows. First, let us find sequential patterns having prefix . Only the sequences containing should be collected. Moreover, in a sequence containing , only the subsequence prefixed with the first occurrence of should be considered. For example, in sequence , only the subsequence should be considered for mining sequential patterns having prefix . Notice that means that the last element in the prefix, which is , together with , form one element. As another example, only the subsequence of sequence should be considered. Sequences in containing are projected w.r.t. to form the -projected database, which consists of four C 64 44 4 )9 8U 64@E664@ D7 9 D 7 9 D C 7 y C 64 9 D C 7 )664@ 9 D7 U 9 D 7 9 D C 7 8R64@E664@ y 64@ 4 4 9 C 7 3.1 Mining sequential patterns by prefix projections: An example #" $ items in ! 2 If is not empty, . the postfix is also denoted as )9 y D7 9 D 7 9 D C 7 8U 64@E664@ 4 T )9 y D7 9 D 7 9 D C 7 @U 64866648G Definition 1 (Prefix, projection, and postfix) Suppose all the items in an element are listed alphabetically. , a sequence Given a sequence is called a prefix of if and only if (1) for ; (2) ; and (3) all the items in are alphabetically after those in . Given sequences and such that is a subsequence of , i.e., . A subsequence of sequence (i.e.,
0 C D 6E9 y U7 9 7 @6EC ( 4 C 4 9 6C 7 6C6D)9 U'7696C48769 7 G y w 4 4 y 4 Since items within an element of a sequence can be listed in any order, without loss of generality, we assume they are listed in alphabetical order. For example, the sequence in with Sequence id 10 in our running example is listed as in stead of . With such a convention, the expression of a sequence is unique. 9 6D y y w U 4 2 4 e da D c e Y X e 6 w 4 D E C 2 2 4 4 In this section, we introduce a new pattern-growth method for mining sequential patterns, called PrefixSpan. Its major idea is that, instead of projecting sequence databases by considering all the possible occurrences of frequent subsequences, the projection is based only on frequent prefixes because any frequent subsequence can always be found by growing a frequent prefix. In Section 3.1, the PrefixSpan idea and the mining process are illustrated with an example. The algorithm PrefixSpan is then presented and justified in Section 3.2. To further improve its efficiency, two optimizations are proposed in Section 3.3 and Section 3.4, respectively. T g 0 Y X ` T T 3 PrefixSpan: Mining Sequential Patterns by Prefix Projections A D A D D A A D D 0 A ) 7 0 ) 9 ) D dA 0 D i w w Aw ) ) 0 0 w D w 9 7 ) ) B w 8 w w w w 0 A w w A 0 A GA A E A 8 A D w A A )9 )9 y A D7 9 D 7 9 7 @U 64866D G y8U 64@E66C G D7 9 D 7 9 D 7 9 D C7 )668R A E A sequence database. All sequential patterns containing only item are also found in this pass. This process is performed recursively on projecteddatabases. Since FreeSpan projects a large sequence database recursively into a set of small projected sequence databases based on the currently mined frequent sets, the subsequent mining is confined to each projected database relevant to a smaller set of candidates. Thus, FreeSpan is more efficient than GSP. The major cost of FreeSpan is to deal with projected databases. If a pattern appears in each sequence of a database, its projected database does not shrink (except for the removal of some infrequent items). For example, the -projected database in this example is the same as the original sequence database, except for the removal of infrequent item . Moreover, since a length- subsequence may grow at any position, the search for lengthcandidate sequence will need to check every possible combination, which is costly.
9 # 5 7 ) is called a projection of w.r.t. prefix if and only if (1) has prefix and (2) there exists no proper super-sequence of (i.e., but ) such that is a subsequence of and also has prefix . be the projection of w.r.t. Let prefix . Sequence is called the postfix of w.r.t. prefix , denoted as , where .2 We also denote . If is not a subsequence of , both projection and postfix of w.r.t. are empty. ) D y w 7 9 D7 9 D C7 U 46866468 A A 5 ) w D R w w w BA ) w 9 D )9 i 9 8 0 y D7 9 D 7 9 D C 7 8U 64@E664@ T A A 9 ) ) 7 i w 0 @7 w c c 7 ) w w w w 1 w 8 A qE D A F y B Prefix , , , , , Table 2. Projected databases and sequential patterns postfix sequences: , , lemma on the completeness of partitioning the sequential and . By scanning -projected pattern mining problem. database once, all the length-2 sequential patterns having prefix can be found. They are: , , Lemma 3.1 (Problem partitioning) Let be a length, , , and . sequential pattern and be the set of all lengthsequential patterns having prefix Recursively, all sequential having patterns prefix . The complete set of sequential patterns having prefix can be partitioned into 6 subsets: (1) those having prefix , except for itself, can be divided into disjoint sub, (2) those having prefix , . . . , and finally, (6) those sets. The subset is the set of sequential having prefix . These subsets can be mined by conpatterns having prefix . Here, we regard as a default structing respective projected databases and mining each sequential pattern for every sequence database. recursively as follows. -projected database consists of only one The Based on Lemma 3.1, PrefixSpan partitions the probnon-empty (postfix) subsequences having prefix : lem recursively. That is, each subset of sequential pat. Since there is no hope to generate any terns can be further divided when necessary. This forms a frequent subsequence from a single sequence, the processdivide-and-conquer framework. To mine the subsets of seing of -projected database terminates. quential patterns, PrefixSpan constructs the correspondThe -projected database consists of three postfix seing projected databases. quences: , , and . Recursively mining -projected database returns four sequential patDefinition 2 (Projected database) Let be a sequenterns: , , , and (i.e., , , tial pattern in sequence database . The -projected , and .) database, denoted as , is the collection of postfixes of projected database contains only two sequences: sequences in w.r.t. prefix . and , which leads to the finding of the following sequential patterns having prefix : To collect counts in projected databases, we have the , , , and . following definition. The -, - and - projected databases can be constructed and recursively mined similarly. The sequential patterns found are shown in Table 2. Similarly, we can find sequential patterns having , , , and , respectively, by conprefix structing -, -, - and -projected databases and mining them respectively. The projected databases as well as the sequential patterns found are shown in Table 2. The set of sequential patterns is the collection of patterns found in the above recursive mining process. One can verify that it returns exactly the same set of sequential patterns as what GSP and FreeSpan do. Definition 3 (Support count in projected database) Let be a sequential pattern in sequence database , and be a sequence having prefix . The support count of in -projected database , denoted as , is such that . the number of sequences in 0 4 )8( U 9 U 7 0 )4@7 f db`C 9 9 U 7 e c a Y Y X 9 D 6 e c a Y Y X 7 7 %f db`C We have the following lemma on projected databases. 3.2 PrefixSpan: Algorithm and correctness Lemma 3.2 (Projected database) Let and be two sequential patterns in sequence database such that is a prefix of .
9 h 9 5 h @7 T 0 P9 h T 1. D Now, let us justify the correctness and completeness of the mining process in Section 3.1. Based on the concept of prefix, we have the following ; A Please note that, in general, . For example, holds in our running example. However, and . 0 )47 9 U 9 A D !` 7 8 )( $ D D 9 D 7 4A E D e c a Y Y X drC` 7 %f 6 F ) D HHH D B D 1 A 1 T D A 1 4 8 A T A T 9 5 h T 8 ! A A 5h T 5 D h T "#1 9 "#! 7 # R$ 7 1 6 %f $0! A T 3 2 1! e c a Y Y X db`C 6 7 f " 9 e c a Y Y X db`C #1 t ! , , , , , "# $) ") ## $) #" # $ " $ 7 1 A A A A ! 4 )9 9 D C7 )668R 44 9 C 7 )64@( 2 w 7 9 D C7 D 9 7 86668Q4U ( C 64 9 D C7 )668R g D 6 g y 44 #"% # )9 y y y D C D 666)9 ( 7 y D7 9 D 7 9 D C 7 8U 64@E664@ 6C6D)9 '7( U )9 @U 64866D ( D7 9 D 7 9 7 y y 9 C 7 648( D 66C4 C 464 D 6 46D ( 6D ( 9 7 9 7 C 64 496D 76 9 D@7U6D4@76ED 76 9 9 y C 64 4 !!& , , # ## # $ $ # ! , , , , , , , "# # # $# %" $ $& # " $# " , , , , , " " ! "# Projected (postfix) database , , ! $# ##(# %$ "#" %$ Sequential patterns , , , , , , , , , , , , , , , , , , , , , , , , , , , . , , , , , , $# C 64 4 6 6 U D C 4 6 6 U D C w y g "#" w U U 4 D U 64 2 Q y )9 D 64 y D7 9 D 7 9 D 7 8U 64@E66C ( 44 C D 66)9 6D4 4 U %1 !' $ " , y g 648( 9 C 7 4 44 D E y U7 9 7 '66C ( 3. The size of -projected database cannot exceed that of . Based on the above reasoning, we have the algorithm of PrefixSpan as follows. Algorithm 1 (PrefixSpan) Input: A sequence database , and the minimum support threshold Output: The complete set of sequential patterns
9 !T 7 Method: Call PrefixSpan
A @7 . Parameters: : a sequential pattern; : the length of ; : the -projected database, if ; otherwise, the sequence database . Method:
5 3.3 Scaling up pattern growth by bi-level projection can be assembled to the last element of to form a sequential pattern; or (b) can be appended to to form a sequential pattern.
A 2. For each frequent item , append it to sequential pattern , and output ;
9 to form a The matrix registers the supports of all the length2 sequences which are assembled using length-1 sequential patterns. A cell at the diagonal line has one counter. For example, indicates sequence appears in three sequences in . Other cells have three D D E6 T 0 D D 1 Projected databases keep shrinking. As indicated in Lemma 3.2, a projected database is smaller than the original one because only the postfix subsequences of a frequent prefix are projected into a projected database. In practice, the shrinking factors can be significant because (1) usually, only a small set of sequential patterns grow quite long in Table 3. The S-matrix. No candidate sequence needs to be generated by PrefixSpan. Unlike -like algorithms, PrefixSpan only grows longer sequential patterns from the shorter frequent ones. It does not generate nor test any candidate sequence nonexistent in a projected database. Comparing with GSP, which generates and tests a substantial number of candidate sequences, PrefixSpan searches a much smaller space. 2 (4, 2, 2) (4, 2, 1) (2, 1, 1) (1, 2, 1) (2, 1, 1) 1 (3, 3, 2) (2, 2, 0) (1, 2, 0) (2, 2, 0) 3 (1, 3, 0) (1, 2, 0) (1, 2, 1) 0 (1, 1, 0) (1, 1, 1) ` U ` D C E E Analysis. The correctness and completeness of the algorithm can be justified based on Lemma 3.1 and Lemma 3.2, as shown in Theorem 3.1 later. Here, we analyze the efficiency of the algorithm as follows. 0 (2, 0, 1) T y w T 5h T 5h T 1 #$1 A $ A '7 3. For each , construct and call PrefixSpan A -projected database . A A A C A C 6 C (a) C h T 1. Scan that once, find the set of frequent items such As analyzed before, the major cost of PrefixSpan is to construct projected databases. If the number and/or the size of projected databases can be reduced, the performance of sequential pattern mining can be improved substantially. In this section, a bi-level projection scheme is proposed to reduce the number and the size of projected databases. Before introducing the method, let us examine the following example. Example 4 Let us re-examine mining sequential patterns in sequence database in Table 1. The first step is the , same: Scan to find the length-1 sequential patterns: , , , and . At the second step, instead of constructing projected databases for each length-1 sequential pattern, we construct a lower triangular matrix , as shown in Table 3. , A A 0 $ A 9 5h T Subroutine PrefixSpan
5 0 9 7 f drC` e c a Y Y X 2. for any sequence having prefix , ; and
9 7 1 '(1 1 $ 1 T T a sequence database, and thus the number of sequences in a projected database will become quite small when prefix grows; and (2) projection only takes the postfix portion with respect to a prefix. Notice that FreeSpan also employs the idea of projected databases. However, the projection there often takes the whole string (not just postfix) and thus the shrinking factor is much less than that of PrefixSpan. The major cost of PrefixSpan is the construction of projected databases. In the worst case, PrefixSpan constructs a projected database for every sequential pattern. If there are a good number of sequential patterns, the cost is non-trivial. In Section 3.3 and Section 3.4, interesting techniques are developed, which dramatically reduces the number of projected databases. Y X ` A 7 %f 6 8 e c a Y Y X drC` T h T Theorem 3.1 (PrefixSpan) A sequence is a sequential pattern if and only if PrefixSpan says so. 1 , where , and A Lemma 3.3 Given a length- sequential pattern . 1. The S-matrix can be filled up after two scans of projected database; and 2. A lengthsequence having prefix is a sequential pattern if and only if the S-matrix in projected database says so. Lemma 3.3 ensures the correctness of bi-level projection. The next question becomes "do we need to include every item in a postfix in the projected databases?" Let us consider the -projected database in Example 4. The S-matrix in Table 3 tells that is a sequential is not. According to the property pattern but , and any super-sequence of it can never be a sequential pattern. So, based on the matrix, we can exclude item from -projected database. This is the 3-way checking to prune items for the efficient construction of projected databases. The principle is stated as follows. Optimization 1 (Item pruning in projected database by 3-way checking) The 3-way checking should be employed to prune items in the construction of projected databases. To construct the -projected database, where is a length- sequential pattern, let be the last element of and be the prefix of such that .
& A A D
9 g 7 If is not frequent, then item from projection.3
& can be excluded
& w Let If 3 For example, suppose is not frequent. Item from construction of -projected database. # # bA w w & & A RbB & c A & A B 0 c A & c c 1. contains one counter. If the last element of has only one item , i.e. , the counter registers the support of sequence (i.e., ) in -projected database. Otherwise, the counter is set to ;
4 be formed by substituting any item in by . is not frequent, then item can be excluded
can be excluded w A A $ A A A 9 &7 @d A w bA 0 A Definition 4 (S-matrix, or sequence-match matrix) Let be a length- sequential pattern, and , , . . . , be all of lengthsequential patterns having prefix within -projected database. The S-matrix of -projected database, denoted as , is defined as follows.
9 Now, let us justify the mining process by bi-level projection.
$ 4U D 64 D E D 4U D 4U 4 U Since there is only one cell with support 2, only one length-2 pattern can be generated and no further projection is needed. Notice that means that it is not possible to generate such a pattern. So, we do not need to look at the database. To mine the complete set of sequential patterns, other projected databases for length-2 sequential patterns should be constructed. It can be checked that such a bi-level projection method produces the exactly same set of sequential patterns as shown in Example 3. However, in Example 3, to find the complete set of 53 sequential patterns, 53 projected databases are constructed. In this example, only projected databases for length-2 sequential patterns are needed. In total, only 22 projected databases are constructed by bi-level projection.
4 A # $ ) A 8 i A ! A BA % 7 C 64 Table 4. The S-matrix in -projected database. A $ 1 ( , 1, ) 4 0 (1, 0, 1) ( , 2, ) If the last element in has only one item , i.e. , counter registers the support of sequence in -projected database. Otherwise, counter is set to ; If the last element in has only one item , i.e. , counter registers the support of sequence in -projected database. Otherwise, counter is set to ; If the last elements in and have the same number of items, counter registers the support of sequence in -projected database, where sequence is but inserting into the last element of the item in the last element of but not in that of . Otherwise, counter is set to . A & A 9 4 4 c A c A A A A cA I c A A A A & c A & A B cA A 7 0 A 9 0 c A 1 1 7 counters respectively. For example, means , and . Since the information in cell is symmetric to that in , a triangle matrix is sufficient. This matrix is called an S-matrix. By scanning sequence database the second time, the S-matrix can be filled up, as shown in Table 3. All the length-2 sequential patterns can be identified from the matrix immediately. For each length-2 sequential pattern , construct -projected database. For example, is identified as a length-2 sequential pattern by S-matrix. The -projected database contains three sequences: , , and . By scanning it once, three frequent items are found: , and . Then, a S-matrix for -projected database is constructed, as shown in Table 4.
9 g C 64 A 9 7 )6D D 1 2. is in the form of are three counters. 8 ! A A 1 c 1 1 2 gY0 467 drC` 9 D f e c a Y Y X 0 D 7 1 T D E A A 4 D 6 2 1 c D 0 648(7 f drC` 9 9 D 7 e c a1 Y Y X 0 E7 db`C 9 D f e c a Y Y X 9 7 46D ( C 64 9 7 4ED ( 9 # $ A A A 7 )9 y 1 D7 9 D 7 9 7 8664866D ( C 64 A A c A A from the first element of postfixes if that element is a superset of .4 This optimization applies the 3-way checking to reduce projected databases further. Only fragments of sequences necessary to grow longer patterns are projected. 4 Experimental Results and Performance Study 3.4 Pseudo-Projection example, suppose is not frequent. To construct -projected database, sequence should be projected to . The first can be omitted. Please note that we must include the second . Otherwise, we may fail to find pattern and those having it as a prefix. # # # 4 For The synthetic datasets we used for our experiments were generated using standard procedure described in . The same data generator has been used in most studies on sequential pattern mining, such as [11, 6]. We refer readers to  for more details on the generation of data sets. We test the four methods on various datasets. The results are consistent. Limited by space, we report here only the results on dataset . In this data set, the number of items is set to , and there are sequences in the data set. The average number of items within elements is set to 8 (denoted as ). The average number of elements in a sequence is set to 8 (denoted as ). There are a good number of long sequential patterns in it at low support thresholds. The experimental results of scalability with support threshold are shown in Figure 1. When the support threshold is high, there are only a limited number of sequential patterns, and the length of patterns is short, the four methods are close in terms of runtime. However, as the support threshold decreases, the gaps become clear. Both FreeSpan and PrefixSpan win GSP. PrefixSpan methods are more efficient and more scalable than FreeSpan, too. Since the gaps among FreeSpan and GSP are clear, we focus on performance of various PrefixSpan techniques in the remaining of this section. As shown in Figure 1, the performance curves of PrefixSpan-1 and PrefixSpan-2 are close when sup 1 $ T 1 ` T The major cost of PrefixSpan is projection, i.e., forming projected databases recursively. Here, we propose a pseudo-projection technique which reduces the cost of projection substantially when a projected database can be held in main memory. By examining a set of projected databases, one can observe that postfixes of a sequence often appear repeatedly in recursive projected databases. In Example 3, sequence has postfixes and as projections in - and -projected databases, respectively. They are redundant pieces of sequences. If the sequence database/projected database can be held in main memory, such redundancy can be avoided by pseudo-projection. The method goes as follows. When the database can be held in main memory, instead of constructing a physical projection by collecting all the postfixes, one can use pointers referring to the sequences in the database as a pseudo-projection. Every projection consists of two pieces of information: pointer to the sequence in database and offset of the postfix in the sequence. For example, suppose the sequence database in Table 1 can be held in main memory. When constructing -projected database, the projection of sequence consists two pieces: a pointer to and offset set to . The offset indicates that the projection starts from position 2 in the sequence, i.e., postfix . Similarly, the projection of in -projected database contains a pointer to and offset set to , indicating the postfix starts from item in . Pseudo-projection avoids physically copying postfixes. Thus, it is efficient in terms of both running time and space. However, it is not efficient if the pseudo-projection is used for disk-based accessing since random access disk space is very costly. Based on this observation, PrefixSpan always pursues pseudo-projection once the projected databases can be held in main memory. Our experimental results show that such an integrated solution, disk-based bi-level projection for disk-based processing and pseudo-projection when data can fit into main memory, is always the clear winner in performance.
0 U 9 D 7 9 D C 64@6E64@7 9 y T C 64 4 D7 U 9 D 7 9 D C 7 8R64@E664@ 2 # # C 64 D 9 9 w In this section, we report our experimental results on the performance of PrefixSpan in comparison with GSP and FreeSpan. It shows that PrefixSpan outperforms other previously proposed methods and is efficient and scalable for mining sequential patterns in large databases. All the experiments are performed on a 233MHz Pentium PC machine with 128 megabytes main memory, running Microsoft Windows/NT. All the methods are implemented using Microsoft Visual C++ 6.0. We compare performance of four methods as follows. GSP. The GSP algorithm was implemented as described in . FreeSpan. As reported in , FreeSpan with alternative level projection is more efficient than FreeSpan with level-by-level projection. In this paper, FreeSpan with alternative level projection is used. PrefixSpan-1. PrefixSpan-1 is PrefixSpan with level-by-level projection, as described in Section 3.2. PrefixSpan-2. PrefixSpan-2 is PrefixSpan with bi-level projection, as described in Section 3.3. y y )9 @U 64866D ( D7 9 D 7 9 7 y D7 9 D 7 9 D C 7 @U E866E8 g D7 9 D 7 9 D C 7 @U E866E8 4 5 Discussions As supported by our analysis and performance study, both PrefixSpan and FreeSpan are faster than GSP, and PrefixSpan is also faster than FreeSpan. Here, we summarize the factors contributing to the efficiency of PrefixSpan, FreeSpan and GSP as follows. gH port threshold is not low. When the support threshold is low, since there are many sequential patterns, PrefixSpan-1 requires a major effort to generate projected databases. Bi-level projection can leverage the problem efficiently. As can be seen from Figure 2, the increase of runtime for PrefixSpan-2 is moderate even when the support threshold is pretty low. Figure 2 also shows that using pseudo-projections for the projected databases that can be held in main memory improves efficiency of PrefixSpan further. As can be seen from the figure, the performance of level-by-level and bilevel pseudo-projections are close. Bi-level one catches up with level-by-level one when support threshold is very low. When the saving of less projected databases overcomes the cost of for mining and filling the S-matrix, bi-level projection wins. That verifies our analysis of level-by-level and bi-level projection. Since pseudo-projection improves performance when the projected database can be held in main memory, a related question becomes: "can such a method be extended to disk-based processing?" That is, instead of doing physical projection and saving the projected databases in hard disk, should we make the projected database in the form of disk address and offset? To explore such an alternative, we pursue a simulation test as follows. Let each sequential read, i.e., reading bytes in a data file from the beginning to the end, cost 1 unit of I/O. Let each random read, i.e., reading data according to its offset in the file, cost unit of I/O. Also, suppose a write operation cost I/O. Figure 3 shows the I/O costs of PrefixSpan-1 and PrefixSpan-2 as well as of their pseudo-projection variations over data set (where means 1 million sequences in the data set). PrefixSpan-1 and PrefixSpan-2 win their pseudoprojection variations clearly. It can also be observed that bi-level projection wins level-by-level projection as the support threshold becomes low. The huge number of random reads in disk-based pseudo-projections is the performance killer when the database is too big to fit into main memory. Figure 4. Scalability of PrefixSpan. Figure 4 shows the scalability of PrefixSpan-1 and PrefixSpan-2 with respect to the number of sequences. Both methods are linearly scalable. Since the support threshold is set to , PrefixSpan-2 performs better. In summary, our performance study shows that PrefixSpan is more efficient and scalable than FreeSpan and GSP, whereas FreeSpan is faster than GSP when the support threshold is low, and there are many long patterns. Since PrefixSpan-2 uses bi-level projection to dramatically reduce the number of projections, it is more efficient than PrefixSpan-1 in large databases with low support threshold. Once the projected databases can be held in main memory, pseudo-projection always leads to the most efficient solution. The experimental results are consistent with our theoretical analysis. C T 5 ` T C Figure 1. PrefixSpan, FreeSpan and GSP on data set . Figure 2. PrefixSpan and PrefixSpan (pseudo-proj) on data set . Figure 3. PrefixSpan and PrefixSpan (pseudo-proj) on large data set . T 5 H H 5 5 C T 5 Prefix-projected pattern growth is more elegant than frequent pattern-guided projection. Comparing with frequent pattern-guided projection, employed in FreeSpan, prefix-projected pattern growth is more progressive. Even in the worst case, PrefixSpan still guarantees that projected databases keep shrinking and only takes care postfixes. When mining in dense databases, FreeSpan cannot gain much from projections, whereas PrefixSpan can cut both the length and the number of sequences in projected databases dramatically. References
 R. Agrawal and R. Srikant. Fast algorithms for mining association rules. In Proc. 1994 Int. Conf. Very Large Data Bases (VLDB'94), pages 487499, Santiago, Chile, Sept. 1994.  R. Agrawal and R. Srikant. Mining sequential patterns. In Proc. 1995 Int. Conf. Data Engineering (ICDE'95), pages 314, Taipei, Taiwan, Mar. 1995.  C. Bettini, X. S. Wang, and S. Jajodia. Mining temporal relationships with multiple granularities in time sequences. Data Engineering Bulletin, 21:3238, 1998.  M. Garofalakis, R. Rastogi, and K. Shim. Spirit: Sequential pattern mining with regular expression constraints. In Proc. 1999 Int. Conf. Very Large Data Bases (VLDB'99), pages 223234, Edinburgh, UK, Sept. 1999.  J. Han, G. Dong, and Y. Yin. Efficient mining of partial periodic patterns in time series database. In Proc. 1999 Int. Conf. Data Engineering (ICDE'99), pages 106115, Sydney, Australia, Apr. 1999.  J. Han, J. Pei, B. Mortazavi-Asl, Q. Chen, U. Dayal, and M.-C. Hsu. Freespan: Frequent pattern-projected sequential pattern mining. In Proc. 2000 Int. Conf. Knowledge Discovery and Data Mining (KDD'00), pages 355359, Boston, MA, Aug. 2000.  J. Han, J. Pei, and Y. Yin. Mining frequent patterns without candidate generation. In Proc. 2000 ACM-SIGMOD Int. Conf. Management of Data (SIGMOD'00), pages 1 12, Dallas, TX, May 2000.  H. Lu, J. Han, and L. Feng. Stock movement and ndimensional inter-transaction association rules. In Proc. 1998 SIGMOD Workshop Research Issues on Data Mining and Knowledge Discovery (DMKD'98), pages 12:112:7, Seattle, WA, June 1998.  H. Mannila, H. Toivonen, and A. I. Verkamo. Discovery of frequent episodes in event sequences. Data Mining and Knowledge Discovery, 1:259289, 1997.  B. Ozden, S. Ramaswamy, and A. Silberschatz. Cyclic association rules. In Proc. 1998 Int. Conf. Data Engineering (ICDE'98), pages 412421, Orlando, FL, Feb. 1998.  R. Srikant and R. Agrawal. Mining sequential patterns: Generalizations and performance improvements. In Proc. 5th Int. Conf. Extending Database Technology (EDBT'96), pages 317, Avignon, France, Mar. 1996. The Apriori property is integrated in bi-level projection PrefixSpan. The Apriori property is the essence of the -like methods. Bi-level projection in PrefixSpan applies the Apriori property in the pruning of projected databases. Based on this property, bi-level projection explores the 3-way checking to determine whether a sequential pattern can potentially lead to a longer pattern and which items should be used to assemble longer patterns. Only fruitful portions of the sequences are projected into the new databases. Furthermore, 3-way checking is efficient since only corresponding cells in -matrix are checked, while no further assembling is needed. 6 Conclusions In this paper, we have developed a novel, scalable, and efficient sequential mining method, called PrefixSpan. Its general idea is to examine only the prefix subsequences and project only their corresponding postfix subsequences into projected databases. In each projected database, sequential patterns are grown by exploring only local frequent patterns. To further improve mining efficiency, two kinds of database projections are explored: level-bylevel projection and bi-level projection, and an optimization technique which explores psuedo-projection is developed. Our systematic performance study shows that A T A Both PrefixSpan and FreeSpan are patterngrowth methods, their searches are more focused and thus efficient. Pattern-growth methods try to grow longer patterns from shorter ones. Accordingly, they divide the search space and focus only on the subspace potentially supporting further pattern growth at a time. Thus, their search spaces are focused and are confined by projected databases. A projected database for a sequential pattern contains all and only the necessary information for mining sequential patterns that can be grown from . As mining proceeds to long sequential patterns, projected databases become smaller and smaller. In contrast, GSP always searches in the original database. Many irrelevant sequences have to be scanned and checked, which adds to the unnecessarily heavy cost. PrefixSpan mines the complete set of patterns and is efficient and runs considerably faster than both -based GSP algorithm and FreeSpan. Among different variations of PrefixSpan, bi-level projection has better performance at disk-based processing, and psuedo-projection has the best performance when the projected sequence database can fit in main memory. PrefixSpan represents a new and promising methodology at efficient mining of sequential patterns in large databases. It is interesting to extend it towards mining sequential patterns with time constraints, time windows and/or taxonomy, and other kinds of time-related knowledge. Also, it is important to explore how to further develop such a pattern growth-based sequential pattern mining methodology for effectively mining DNA databases. ...
View Full Document
This note was uploaded on 09/21/2009 for the course CS 580 taught by Professor Fdfdf during the Spring '09 term at University of Toronto- Toronto.
- Spring '09