Table of Contents
Fetching ...

Shapelet-based Model-agnostic Counterfactual Local Explanations for Time Series Classification

Qi Huang, Wei Chen, Thomas Bäck, Niki van Stein

TL;DR

This work tackles the challenge of explainability for time series classifiers by introducing Time-CF, a model-agnostic, instance-level counterfactual explanation framework that combines shapelet Transform with TimeGAN to generate plausible counterfactual sequences. By replacing contiguous subsequences identified via shapelets with TimeGAN-generated alternatives and selecting those that flip the classifier's prediction with minimal perturbation, Time-CF delivers faithful, interpretable explanations. Across four binary UCR datasets and multiple classifiers, Time-CF demonstrates strong performance in closeness ($L_1$-norm distance), sensibility (model-agnostic applicability), plausibility (low outlier rates), and sparsity (localized perturbations). The method offers practical impact for diagnosing decision boundaries in time series and sets a path for extending to multi-class and multivariate tasks, while highlighting areas for improving performance on imbalanced data.

Abstract

In this work, we propose a model-agnostic instance-based post-hoc explainability method for time series classification. The proposed algorithm, namely Time-CF, leverages shapelets and TimeGAN to provide counterfactual explanations for arbitrary time series classifiers. We validate the proposed method on several real-world univariate time series classification tasks from the UCR Time Series Archive. The results indicate that the counterfactual instances generated by Time-CF when compared to state-of-the-art methods, demonstrate better performance in terms of four explainability metrics: closeness, sensibility, plausibility, and sparsity.

Shapelet-based Model-agnostic Counterfactual Local Explanations for Time Series Classification

TL;DR

This work tackles the challenge of explainability for time series classifiers by introducing Time-CF, a model-agnostic, instance-level counterfactual explanation framework that combines shapelet Transform with TimeGAN to generate plausible counterfactual sequences. By replacing contiguous subsequences identified via shapelets with TimeGAN-generated alternatives and selecting those that flip the classifier's prediction with minimal perturbation, Time-CF delivers faithful, interpretable explanations. Across four binary UCR datasets and multiple classifiers, Time-CF demonstrates strong performance in closeness (-norm distance), sensibility (model-agnostic applicability), plausibility (low outlier rates), and sparsity (localized perturbations). The method offers practical impact for diagnosing decision boundaries in time series and sets a path for extending to multi-class and multivariate tasks, while highlighting areas for improving performance on imbalanced data.

Abstract

In this work, we propose a model-agnostic instance-based post-hoc explainability method for time series classification. The proposed algorithm, namely Time-CF, leverages shapelets and TimeGAN to provide counterfactual explanations for arbitrary time series classifiers. We validate the proposed method on several real-world univariate time series classification tasks from the UCR Time Series Archive. The results indicate that the counterfactual instances generated by Time-CF when compared to state-of-the-art methods, demonstrate better performance in terms of four explainability metrics: closeness, sensibility, plausibility, and sparsity.
Paper Structure (11 sections, 1 equation, 6 figures)

This paper contains 11 sections, 1 equation, 6 figures.

Figures (6)

  • Figure 1: The flowchart of Time-CF in binary classification. The process describes how the counterfactual explanation of an instance labeled as Class A, is synthesized by TimeGAN and shapelet transform, based on instances from Class B.
  • Figure 2: An example of a time series counterfactual instance, where the blue curve represents the to-be-explained shapelet of the electrocardiogram instance from the UCR ECG200 UCRArchive. The orange curve stands for its generated counterfactual subsequence, which drives the classifier to alter its prediction.
  • Figure 3: The results of L1-norm closeness. A low value is preferred, as it indicates less scale change.
  • Figure 4: Assessment of sensibility, where higher values (darker in plot) are preferable. The figure displays the ratios of each post-hoc explainer in successfully finding counterfactual instances across four datasets.
  • Figure 5: Assessment of plausibility, where a lower value is preferable. The y-axis quantifies the outlier ratios of the generated counterfactual instances.
  • ...and 1 more figures