[Paper Review] Diverse Counterfactual Explanations for Anomaly Detection in Time Series
This paper proposes a model-agnostic method for generating diverse counterfactual explanations in time series anomaly detection by producing multiple perturbed versions of anomalous sequences that the model classifies as normal. The approach uses probabilistic forecasting and gradient-free optimization to ensure validity, plausibility, and diversity, significantly improving interpretability—especially with sparse variants in high-dimensional settings.
Data-driven methods that detect anomalies in times series data are ubiquitous in practice, but they are in general unable to provide helpful explanations for the predictions they make. In this work we propose a model-agnostic algorithm that generates counterfactual ensemble explanations for time series anomaly detection models. Our method generates a set of diverse counterfactual examples, i.e, multiple perturbed versions of the original time series that are not considered anomalous by the detection model. Since the magnitude of the perturbations is limited, these counterfactuals represent an ensemble of inputs similar to the original time series that the model would deem normal. Our algorithm is applicable to any differentiable anomaly detection model. We investigate the value of our method on univariate and multivariate real-world datasets and two deep-learning-based anomaly detection models, under several explainability criteria previously proposed in other data domains such as Validity, Plausibility, Closeness and Diversity. We show that our algorithm can produce ensembles of counterfactual examples that satisfy these criteria and thanks to a novel type of visualisation, can convey a richer interpretation of a model's internal mechanism than existing methods. Moreover, we design a sparse variant of our method to improve the interpretability of counterfactual explanations for high-dimensional time series anomalies. In this setting, our explanation is localised on only a few dimensions and can therefore be communicated more efficiently to the model's user.
Motivation & Objective
- To address the lack of actionable and interpretable explanations for anomalies detected by complex deep learning models in time series.
- To generate counterfactual explanations that show what minimal changes to the input would make the model classify a sequence as normal.
- To ensure explanations are diverse, plausible, and close to the original input while being applicable to any differentiable anomaly detection model.
- To improve interpretability in high-dimensional multivariate time series by introducing a sparse variant that localizes changes to a few key dimensions.
- To evaluate the method across multiple explainability criteria—Validity, Plausibility, Closeness, and Diversity—on real-world datasets.
Proposed method
- Uses a model-agnostic framework to generate counterfactual ensembles by perturbing anomalous time series inputs to produce outputs classified as normal by the detection model.
- Employs probabilistic forecasting (e.g., DeepVAR) as a generative prior to guide the perturbation process and improve plausibility.
- Applies a gradient-free optimization strategy based on dynamic perturbations and distance constraints to ensure the counterfactuals are close to the original sequence.
- Introduces a sparse variant that restricts perturbations to only a subset of dimensions, enhancing interpretability in high-dimensional multivariate time series.
- Optimizes counterfactuals using a loss function combining prediction deviation penalty and input distance, with trade-off hyperparameter λ.
- Uses Dynamic Time Warping (DTW) and temporal smoothness metrics to evaluate plausibility, and diversity is measured via inter-counterfactual distance.
Experimental results
Research questions
- RQ1Can counterfactual explanations effectively guide users toward actionable changes that would prevent future anomaly detection?
- RQ2How can diverse, plausible, and minimally perturbed counterfactuals be generated for time series anomaly detection models?
- RQ3To what extent does introducing sparsity in perturbations improve interpretability in high-dimensional multivariate time series?
- RQ4How do different optimization strategies (e.g., gradient-based vs. sampling-based) compare in terms of validity, plausibility, and diversity?
- RQ5Can the method generalize across different deep learning-based anomaly detection models (e.g., USAD, NCAD) and real-world datasets?
Key findings
- The proposed method achieved 0% failure rate on the USAD model across multivariate datasets, with the sparse variant improving success rates on the more complex NCAD model.
- The FS (feature-saliency-based) method produced the most realistic counterfactuals, achieving the lowest implausibility scores (1.62 for Implausibility 1 and 1.49 for Implausibility 2) on the USAD model.
- The gradient-based ICE method achieved the best Distance score (31.81) on USAD, indicating high closeness to the original input, while maintaining low failure rates.
- The sparse DPE variant achieved a precision of 0.68 and recall of 0.07 on the USAD model, correctly identifying key anomalous channels in high-dimensional data.
- The method significantly outperformed the naive baseline in all metrics, with the naive method failing in 73.4% of cases on USAD and 79.8% on NCAD.
- Diversity was highest for the ICE method (4639.11 on NCAD), indicating strong ensemble diversity, while FS achieved the best balance of plausibility and diversity.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.