Abstract
Deep learning models for time series classification often operate as "black boxes," making them difficult to deploy in high-stakes environments like healthcare and finance. Traditional post-hoc explanation methods typically evaluate importance at the individual timestep level, which disrupts the cohesive temporal patterns—or shapelets—that drive model decisions. This paper introduces ShapeX, a novel framework that learns discriminative subsequences to segment time series data and applies Shapley values to these semantically meaningful units. By preserving the atomicity of temporal features, ShapeX provides causally grounded, high-fidelity explanations that significantly outperform existing state-of-the-art methods.
Introduction
In domains such as electrocardiogram (ECG) analysis or financial forecasting, understanding why a model reached a specific conclusion is as important as the accuracy of the prediction itself. Post-Hoc Time Series Explanation (PHTSE) methods aim to provide this transparency by generating saliency scores. However, current techniques like Dynamask or Integrated Gradients often suffer from a fundamental mismatch with time series data: they perturb data at the timestep level or via arbitrary windows.
Because time series classification is usually driven by specific morphological subsequences (e.g., the QRS complex in a heartbeat), perturbing individual points breaks local temporal dependencies. This results in noisy, fragmented explanations that fail to capture the true causal drivers of the model's behavior. ShapeX addresses this by shifting the focus from individual points to "shapelets"—the atomic units of meaning in time series data.
The ShapeX Framework
ShapeX operates through a two-phase process: learning the underlying patterns and then using those patterns to generate explanations.
1. Shapelet Describe-and-Detect (SDD)
Rather than relying on a pre-defined library of patterns, ShapeX learns a compact and diverse set of shapelets tailored to the specific dataset. The SDD module utilizes a descriptor-detector layer and a multi-head self-attention shapelet encoder. This module is optimized using a composite loss function designed to ensure:
- Classification Expressiveness: The shapelets must be useful for distinguishing between classes.
- Morphological Matching: The learned shapelets must align with actual shapes found in the input data.
- Diversity: The framework avoids redundant patterns, ensuring a broad representation of the data's features.
2. Shapelet-Driven Segmentation and Attribution
During the inference phase, ShapeX scans the input time series and segments it based on the activation of the learned shapelets. Once the series is partitioned into these meaningful segments, the framework computes the Shapley value for each segment. This determines the marginal contribution of each shapelet to the final model output.
To simulate the "removal" of a segment for Shapley computation without creating artificial discontinuities, ShapeX employs linear interpolation perturbation. By interpolating between the boundaries of a segment, the framework avoids the jarring "zero-masking" artifacts that often confuse deep learning models during the explanation process.
Causal Grounding and Theoretical Insights
One of the primary contributions of ShapeX is its mathematical foundation in causality. The authors demonstrate that by treating the masking of a cohesive, shapelet-aligned segment as a formal intervention, the resulting Shapley values approximate the model-level Conditional Average Treatment Effect (CATE). This moves the explanation beyond simple correlation, identifying the actual causal drivers of the model's decision-making process.
Experimental Evaluation
The researchers evaluated ShapeX against several state-of-the-art baselines, including TIMEX++, Dynamask, and WinIT, across both synthetic and real-world datasets.
Synthetic Benchmarks
The authors introduced four new motif-based datasets (MCC-E, MTC-H, MCC-H, MTC-E) featuring ground-truth saliency. Unlike previous benchmarks that relied on extreme amplitude spikes, these datasets reflect the subtle morphological patterns found in real-world scenarios. On these benchmarks, ShapeX outperformed the second-best method by an average of 58.12% in AUPRC (Area Under Precision-Recall Curve), with gains reaching up to 146% in specific cases.
Real-World Application
- ECG Analysis: Using expert-annotated data for atrial fibrillation, ShapeX consistently identified the correct physiological indicators more accurately than competing methods.
- UCR Time Series Archive: In an extensive occlusion test across 114 datasets—the largest evaluation of its kind in PHTSE literature—ShapeX exhibited the smoothest performance degradation curve, proving its robustness across diverse domains such as motion analysis and astronomy.
- Qualitative Case Study: In bone maturity analysis (
PhalangesOutlinesCorrect), ShapeX correctly highlighted the growth plate transition region, whereas other methods focused on irrelevant peaks and valleys.
Conclusion and Future Work
ShapeX represents a significant advancement in making time series models interpretable. By prioritizing the "atomicity" of temporal patterns, it provides explanations that are both human-readable and mathematically rigorous. While the framework currently requires manual tuning of hyperparameters like shapelet length and count, it sets a new standard for fidelity in time series explanations. Future research will focus on automating hyperparameter selection and extending the framework to handle multivariate and irregular time series data.
Summary updated