Abstract
Sequence mining is a cornerstone of data analysis, yet traditional algorithms are often difficult to adapt to specific user requirements. This paper introduces a declarative framework for sequence mining using Constraint Programming (CP). We propose two CP formulations: a Global Model optimized for performance through projected frequency and a Decomposed Model designed for maximum flexibility. Our results demonstrate that this CP-based approach is competitive with specialized algorithms while allowing for the seamless integration of diverse constraints.
Introduction
Sequence mining involves discovering frequent ordered patterns within transactional databases, with applications ranging from bioinformatics to web usage analysis. While specialized algorithms like PrefixSpan and cSpade offer high performance, they are typically "hard-coded" for specific tasks. Modifying these algorithms to include custom constraints—such as limiting the gap between symbols—requires deep changes to their internal pruning logic and data structures.
To address this, we propose a shift toward Constraint Programming. In a CP framework, users can simply state their constraints (e.g., pattern length, frequency, or gap limits) without needing to understand the underlying search implementation. This approach transforms constraints from a computational burden into an asset that helps prune the search space.
Methods and Models
The proposed framework categorizes constraints into four distinct types:
- Pattern Constraints: Constraints on the structure of the pattern itself (e.g., minimum length).
- Cover Set Constraints: Constraints on the frequency or support of the pattern in the database.
- Inclusion Relation Constraints: Constraints on how the pattern is embedded within a transaction (e.g., max-gap or max-span).
- Preference Constraints: Constraints that define the desired output, such as finding only "closed" patterns.
To implement these, we introduce two CP models:
The Global Model
The Global Model utilizes a specialized global constraint called exists-embedding. This model is highly efficient as it incorporates "projected frequency," a technique borrowed from specialized algorithms to prune the search space early. However, because it abstracts the internal mapping of patterns to data, it cannot easily handle Type 3 constraints like max-gap.
The Decomposed Model
The Decomposed Model explicitly exposes "embedding variables" that track the exact position of each symbol within a transaction. This provides the flexibility needed to handle all four constraint types, including complex distance-based rules.
As shown in the figure above, the inclusion relation determines whether a pattern $S$ exists within a transaction $T$. In this example, pattern $S = (A, B)$ is present in $T_1$ ($C_1=1$) but not in $T_2$ ($C_2=0$) because the order of symbols is not preserved.
Experimental Evaluation
We evaluated our models on four real-world datasets: Unix user command sequences, JMLR abstracts, iPRG proteomics data, and FIFA clickstream data.
Key Results
- Performance: The Global Model is approximately an order of magnitude faster than the Decomposed Model.
- Pruning Efficiency: On the Unix dataset, mining at a 5% frequency threshold was only possible when adding a "max-span" constraint, which reduced the search space enough to complete the task in seconds.
- Competitiveness: The CP-based
global-p.f.model performed similarly toPrefixSpanand outperformed other CP approaches using DFA encodings. - Flexibility: We successfully performed exploratory analysis on the Unix dataset, identifying specific command sequences like
latex -> bibtex -> latexby layering simple constraints.
Conclusion
This research demonstrates that Constraint Programming is a viable and powerful tool for sequence mining. By bridging the gap between specialized data mining tricks and general-purpose solvers, we provide a framework that is both efficient and highly customizable. Future work will focus on developing more efficient global constraints to handle Type 3 constraints, potentially combining the speed of the Global Model with the flexibility of the Decomposed Model.
Summary updated