Introduction
When an AI model predicts a medical event like a heart attack from an electrocardiogram (ECG), clinicians need to understand why that prediction was made. Most existing explanation methods provide "point-wise" saliency, highlighting individual, disconnected timestamps across the sequence. However, time-series data is inherently interconnected; a single data point is rarely meaningful on its own. Instead, the diagnostic information lies in the shape of the wave over a specific interval.
Existing methods generally fall into two traps:
- Fragmentation: Point-wise methods produce "salt-and-pepper" noise, highlighting disconnected dots that fail to form a coherent pattern.
- Rigidity: "Patch-wise" methods use fixed-length windows that cannot adapt to the natural boundaries of a signal, often cutting off important features or including irrelevant noise.
TimeSeg is a novel framework designed to bridge this gap. It explains time-series model predictions by identifying variable-length, contiguous "segments" of data that drive model decisions, providing human-interpretable explanations even for strict black-box models.
Methodology
TimeSeg frames the search for explanatory segments as an information-theoretic optimization problem. The objective is to select contiguous subsequences that maximize the Mutual Information (MI) between the selected data and the model's original prediction.
Because calculating joint MI for all possible segment combinations is computationally intractable, TimeSeg introduces several key innovations:
- Sequential Selection via RL: The explainer acts as a Reinforcement Learning (RL) agent. It sequentially picks segments by calculating the Conditional Mutual Information (CMI)—evaluating how much new information a segment adds given what has already been selected.
- Two-Step Policy: To ensure valid, contiguous segments, the agent's policy is factored into two steps: selecting a start index, and then selecting an end index from the remaining valid range.
- Adaptive Termination: TimeSeg uses a threshold-based stopping rule, halting the addition of segments when the marginal information gain drops too low. This allows for shorter explanations in simple cases and longer ones for complex signals.
- Strict Black-Box Operation: TimeSeg only requires access to the model's inputs and outputs, making it compatible with any pre-trained model (e.g., CNNs, RNNs, Transformers) without needing internal weights or gradients.
Key Results and Insights
TimeSeg was evaluated across synthetic datasets and real-world benchmarks, including MIT-ECG (heartbeat recordings), Epilepsy EEG data, Wafer sensor data, and GunPoint motion capture.
Superior Localization: On the MIT-ECG dataset, where "ground truth" segments (QRS complexes) are annotated by cardiologists, TimeSeg achieved an F1 score of 0.739 and an Intersection over Union (IoU) of 0.621. This significantly outperformed the previous state-of-the-art, TimeX++, which scored 0.593 and 0.460, respectively.
Visual Coherence: As demonstrated in the comparison above, while baseline methods like TimeX++ produce scattered, fragmented highlights, TimeSeg consistently "wraps" around meaningful peaks and valleys, providing a cohesive visual explanation that aligns with human intuition.
High Fidelity: In occlusion tests—where identified segments are removed to see if the model's prediction changes—TimeSeg's segments proved to be much more necessary to the model's logic than those identified by competing methods.
Limitations and Future Work
Currently, TimeSeg's reward mechanism is purely mathematical (information gain). Future iterations could incorporate domain-specific priors, such as incentivizing segments that align with known physiological patterns in medical data. Additionally, the framework is well-suited for human-in-the-loop preference learning, allowing specialists to guide the RL agent toward even more meaningful segmentations. Finally, while inference is fast, training the RL agent requires multiple queries to the black-box model, which may introduce computational overhead for extremely large models.
Summary updated