Abstract
Sequential Pattern Mining (SPM) is a vital technique for discovering recurring sub-sequences in large databases, yet it often suffers from high noise and computational inefficiency when dealing with complex constraints. We present Seq2Pat, a high-performance Python library that leverages Multi-valued Decision Diagrams (MDDs) to bridge the gap between pattern mining and machine learning. Seq2Pat efficiently handles non-monotone constraints—such as average values or time spans—directly during the mining process. Our evaluation on a large-scale online shopper behavior dataset demonstrates that integrating Seq2Pat-generated patterns as features into deep learning models significantly enhances predictive performance, achieving a Recall of 73.64% and an AUC of 96.76%, while simultaneously providing actionable model explainability.
Introduction
Sequential data is ubiquitous, from customer journeys to genomic sequences. While SPM identifies frequent sub-sequences, standard algorithms often produce an overwhelming number of trivial patterns. Constraint-Based SPM (CSPM) addresses this by filtering for "interesting" patterns. However, existing CSPM tools often struggle with non-monotone constraints and lack integration with modern Python-based data science workflows. Seq2Pat addresses these challenges by providing a scalable, MDD-based engine with a user-friendly Python interface.
Methodology: MDD-Based Constraint Mining
Seq2Pat's core innovation is the use of Multi-valued Decision Diagrams (MDDs) to represent sequence databases compactly. Unlike traditional tree-based search, the MDD structure allows for early pruning of paths that violate constraints. This is particularly effective for non-monotone constraints, where the validity of a pattern can change as items are added. Seq2Pat supports a declarative API, allowing users to specify complex constraints (e.g., average price, median, or temporal gaps) that are enforced during the mining phase rather than as a post-processing step.
Experimental Evaluation
The effectiveness of Seq2Pat was tested on a public dataset of 203,084 clickstream sequences from online shoppers. The goal was to predict purchase intent based on user actions (e.g., page views, adding to cart). We compared standalone models (LightGBM, LSTM) against a hybrid approach that combines raw sequence data with patterns discovered by Seq2Pat.
Results and Explainability
As shown in the performance metrics, the hybrid LSTM_seq2pat model outperformed all others, reaching a Recall of 73.64% and an AUC of 96.76%. This suggests that automated feature engineering via pattern mining captures high-level behavioral signals that raw LSTMs might miss.
Beyond raw performance, Seq2Pat enhances model interpretability. By applying SHAP (SHapley Additive exPlanations) values to the discovered patterns, we can identify which specific sequences drive predictions. For instance, the pattern 311 (representing ⟨Add to Cart, Page View, Page View⟩) was found to be a strong positive indicator of purchase intent.
Conclusion
Seq2Pat provides a robust bridge between sequence mining and machine learning. By making complex constraint-based mining accessible in Python, it enables data scientists to automate feature engineering and improve both the performance and explainability of sequence models. Future research will explore the application of Seq2Pat to continuous time-series data and its integration as a differentiable layer in neural networks.
Summary updated