- Introduced by
- Rakesh Agrawal & Ramakrishnan Srikant
- Year
- 1995
- Type
- Unsupervised pattern discovery
- Family
- Pattern mining
What does it do?
Sequential Pattern Mining discovers ordered patterns that recur across multiple event sequences in a database.
Introduced by Agrawal and Srikant in 1995, it extends association-rule mining to time-ordered transactions. A pattern is frequent when it appears as an ordered subsequence in at least a user-specified fraction of all sequences. The method is widely applied wherever the order of events carries meaning, such as customer purchase histories, clickstream logs, electronic health records, and DNA sequence analysis.
The intuition behind the method
Imagine reviewing thousands of customers' shopping histories and asking which sequences of product categories many shoppers follow over time. Sequential Pattern Mining answers this by systematically searching for ordered lists of itemsets that appear in enough histories. Unlike basket analysis, which ignores order, the method treats the timeline as part of the pattern. If many users buy a camera, then a memory card, then a camera bag over successive visits, that chain is reported as a sequential pattern because it meets the support threshold, not because it is proven to be a causal sequence.
History
Agrawal and Srikant's 1995 ICDE paper extended the Apriori association-rule framework to ordered customer transactions. The paper presented three algorithms for mining sequential patterns, including AprioriAll and AprioriSome, and evaluated them on synthetic data. Subsequent work, including the FreeSpan, PrefixSpan, and SPADE algorithms, moved away from candidate generation toward pattern-growth and vertical database formats to reduce the number of database scans.
When to use it
Use Sequential Pattern Mining when each entity in your data has an ordered history of events or itemsets, such as purchases, clicks, or visits, and you want to find which ordered patterns recur across entities without a predefined outcome label. The method needs a minimum support value chosen by the analyst, and it assumes the sequences being compared are drawn from a comparable population. Do not choose it when the order of events carries no meaning, when you need a model that predicts a labelled outcome (a supervised sequence model is more appropriate), when the database is so sparse that few sequences share any ordered pattern, or when the time gaps between events are the main object of analysis, in which case episode mining or temporal-logic approaches are better suited.
Limitations and considerations
- The candidate space grows exponentially with pattern length, so very low support thresholds become computationally expensive.
- The minimum support value must be chosen by the user, and this choice directly determines which patterns are returned.
- The basic formulation models only relative order, not time. Two sequences with the same order but very different time lags are treated identically unless a time-constrained extension is used.
- High-dimensional item spaces (many distinct items) increase memory use and processing time, since more candidate sequences must be generated and counted.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Represents order explicitly: the same items bought in a different sequence are counted as different patterns, which unordered basket analysis cannot distinguish.
- The anti-monotone property means that if a sequence is infrequent, all of its extensions are infrequent too, so whole branches of the candidate space can be discarded without counting them in the database.
- Each output pattern is an ordered sequence with a support value, so it can be read directly and used as an input to recommendation or prediction tasks.
- In the original paper's synthetic-data experiments, both AprioriSome and AprioriAll scaled roughly linearly with the number of customer transactions, and later variants were designed to reduce the number of database scans.
Applications
- E-commerce recommendation: surfacing purchase sequences to personalize product suggestions.
- Healthcare: identifying ordered sequences of diagnoses or treatments associated with patient outcomes.
- Web usage mining: discovering common clickstream paths through websites to optimize navigation design.
- Bioinformatics: finding conserved motifs in DNA or protein sequences across species.
- Educational data mining: detecting learning behavior sequences predictive of course completion or failure.
How it works
How it works
The algorithm first scans the database to find every individual item (length-1 sequence) whose support, the fraction of sequences in which it appears, meets or exceeds the minimum support threshold. These frequent single items form the seed set from which longer candidate sequences are built.
Formula
L_1 = \{ \langle i \rangle \mid \text{support}(\langle i \rangle) \geq \text{minsup} \}Length-k candidates are formed by joining pairs of frequent (k-1)-sequences whose overlapping parts match: the first sequence with its first item removed must equal the second with its last item removed. The result is the first sequence extended by the last item of the second, either added to the last element (a set-wise extension) or appended as a new element (a temporal extension). Under the anti-monotone principle, a candidate is kept only if its subsequences are already known to be frequent, so candidates that cannot be frequent are not counted in the database.
Formula
C_k = \{ s_1 \oplus \text{last}(s_2) \mid s_1, s_2 \in L_{k-1},\ s_1[2{:}k{-}1] = s_2[1{:}k{-}2] \}The database is scanned to count how many customer sequences contain each candidate as a subsequence. A sequence s is contained in a database entry c if each itemset of s appears in c in the same relative order, though not necessarily in consecutive positions. Support is this count divided by the number of sequences in the database.
Formula
\text{support}(s) = \frac{|\{ c \in \mathcal{D} \mid s \text{ is a subsequence of } c \}|}{|\mathcal{D}|}Candidates whose support falls below the minimum support threshold are discarded, and the survivors become the frequent sequences of length k. The index k is increased by one and the process repeats until no candidate of the next length survives.
Formula
L_k = \{ s \in C_k \mid \text{support}(s) \geq \text{minsup} \},\quad k \leftarrow k + 1Common pitfalls
- Setting minimum support too low floods the results with trivially frequent or redundant patterns, and with a large candidate space it also increases the number of patterns that arise by chance, which makes interpretation difficult.
- Treating timestamps as discrete transactions without aligning granularity can merge events that belong to different logical sessions into one sequence.
- Confusing sequence mining with time-series forecasting leads to category errors: the method finds recurring ordered patterns and does not produce a predictive model.
- Ignoring the difference between item order within an itemset and order between itemsets produces incorrect subsequence containment checks, because items inside one itemset are not ordered.
- Reading a reported pattern as a causal or predictive relationship. Support is a descriptive frequency; check patterns on held-out sequences or with domain experts before using them for decisions.
Frequently asked questions
How does Sequential Pattern Mining differ from association rule mining?
Association rule mining finds co-occurring itemsets within a single transaction without regard to order. Sequential Pattern Mining extends this by requiring items or itemsets to appear in a specific temporal order across multiple transactions. The ordering constraint makes it suitable for use cases where the sequence of events — not just their co-occurrence — is the object of study.
What is the role of the minimum support threshold?
Minimum support is the fraction of database sequences in which a candidate pattern must appear as an ordered subsequence to be considered frequent. It is the primary tuning parameter: too high and rare but meaningful patterns are pruned away; too low and the result set becomes unmanageably large and contains more chance patterns. Analysts typically explore several thresholds or use domain knowledge to set a meaningful baseline.
Can Sequential Pattern Mining handle time gaps between events?
The basic Agrawal and Srikant formulation does not model inter-event time gaps; it cares only about relative order. Later extensions introduced time constraints such as maximum gap and sliding windows, allowing analysts to restrict patterns to sequences where consecutive events occur within a specified time interval, making the results more operationally meaningful.
Related methods
Sources
Agrawal, R., & Srikant, R. (1995). Mining sequential patterns. IEEE International Conference on Data Engineering (ICDE), 3–14.
Open DOI referenceData Mining (2015), Section 15.2 Sequential Pattern Mining, p. 499