ConTex: Counterfactual Time Series Explanations
- ConTex is a method enabling minimal, plausible modifications to time series data to alter model outputs for both classification and forecasting tasks.
- It decomposes interventions into temporal relevance masks and modification strength signals using architectures like BiLSTM or TCN for real-time counterfactual generation.
- Empirical studies show ConTex significantly reduces computation costs while achieving high validity, sparsity, and actionability under complex temporal constraints.
Counterfactual Time Series Explanations (ConTex) are what-if explanations for temporal models: they show how a given time series would need to change, minimally and plausibly, to alter a model’s output. In current usage, the term denotes both a broader research area spanning time series classification and forecasting, and a specific forecasting architecture named ConTex that learns a global intervention policy rather than solving a new optimization problem for every instance (Schlegel et al., 29 Mar 2026, Voets et al., 16 Jun 2026). Across this literature, the central technical concerns are validity, proximity, sparsity, plausibility, temporal coherence, and actionability under the distinctive constraints of temporal order, dynamic dependence, and multivariate coupling (Schlegel et al., 29 Mar 2026).
1. Conceptual and formal foundations
For time series classification, the basic formulation seeks an alternative sequence such that the predicted label changes while the modification remains small. In the general survey formulation, with classifier , a counterfactual satisfies and is obtained by minimizing a validity term together with a distance ; pointwise norms such as and , and shape-aware distances such as Dynamic Time Warping, are all used in practice (Schlegel et al., 29 Mar 2026). The univariate interactive framework for classification makes the same objective explicit as
for a series and classifier (Schlegel et al., 2024).
For forecasting, the formulation shifts from label flipping to target trajectories or forecast bounds. ForecastCF defines a forecasting model and searches for a modified back-horizon sequence whose forecast lies within lower and upper bound vectors 0 and 1 (Wang et al., 2023). The ConTex forecasting paper expresses the target as
2
and defines the counterfactual as
3
with 4 combining an 5 deviation term and a penalty on the number of significantly altered timesteps (Voets et al., 16 Jun 2026). In multivariate forecasting, a related formulation targets a desired forecast 6 within tolerance 7, using Granger causality, quantile regression, and genetic search over future trajectories (Zuin et al., 1 Mar 2026).
2. Methodological families
A recent survey organizes the field into six main families: optimization-based, evolutionary, instance-based, latent-space, segment-based, and hybrid methods (Schlegel et al., 29 Mar 2026). These families differ primarily in where the search is performed, how plausibility is enforced, and what kind of intervention structure is considered meaningful.
| Family | Core mechanism | Representative papers |
|---|---|---|
| Optimization-based | Direct perturbation in input or feature space | (Wang et al., 2023, Kostrzewa et al., 9 Mar 2026) |
| Instance- and pattern-based | Reuse of real examples, motifs, shapelets, or symbolic patterns | (Delaney et al., 2020, Li et al., 2022, Huang et al., 2024, Płudowski et al., 28 Mar 2025) |
| Evolutionary multi-objective | NSGA-II or genetic search over subsequences or references | (Huang et al., 2024, Refoyo et al., 2024) |
| Generative / latent-space | VAE or GAN latent search with realism constraints | (Lang et al., 2022, Seifi et al., 25 Sep 2025) |
| Interactive visual analytics | Counterfactual generation by direct manipulation in 2D projections | (Schlegel et al., 2024) |
Instance-based methods emphasize reuse of real data. Native Guide retrieves a nearest unlike neighbor and adapts it by replacing discriminative contiguous segments, yielding counterfactuals that are proximal, sparse, plausible, and optionally diverse (Delaney et al., 2020). MG-CF replaces one motif of the predicted class with a target-class motif mined by Shapelet Transform, with validity, proximity, sparsity, contiguity, model-agnosticism, and efficiency as explicit desiderata (Li et al., 2022). Time-CF combines shapelets with TimeGAN so that a discriminative segment of the original series is replaced by a plausible generated segment from the other class (Huang et al., 2024). MASCOTS moves the search into a symbolic Bag-of-Receptive-Fields representation and performs pattern replacement in a model-agnostic way for both univariate and multivariate data (Płudowski et al., 28 Mar 2025).
Evolutionary methods encode counterfactuals as subsequences, references, or masks and optimize several objectives simultaneously. TX-Gen uses NSGA-II with a compact chromosome encoding a single subsequence and a reference index, jointly minimizing a classifier-space reference objective and a sparsity–proximity objective (Huang et al., 2024). Multi-SpaCE extends the subsequence paradigm to multivariate time series with explicit objectives for adversarial confidence, sparsity, contiguity, and plausibility, and reports perfect validity in its experiments (Refoyo et al., 2024).
Generative approaches seek realism by learning the data manifold. SPARCE uses a residual GAN architecture with a custom sparsity layer and regularizes the generator by similarity, sparsity, and smoothness of trajectories (Lang et al., 2022). GenFacts uses a class-discriminative variational autoencoder with contrastive and classification-consistency objectives, prototype-based initialization, and realism-constrained latent optimization; it reports a plausibility gain of 8 and the highest interpretability scores in a human study (Seifi et al., 25 Sep 2025). The interactive visual-analytics approach to univariate classification is distinct again: it uses UMAP projections, inverse projection, and dense decision boundary maps so that counterfactuals can be generated by dragging points across projected decision regions (Schlegel et al., 2024).
3. The specific ConTex architecture for forecasting
The method explicitly named ConTex reformulates counterfactual generation for time series forecasting as learning a globally consistent intervention strategy rather than performing instance-wise optimization (Voets et al., 16 Jun 2026). Its intervention is decomposed as
9
where 0 is a temporal relevance mask, 1 is a modification-strength signal, 2 is the current forecast, and 3 encodes the target condition (Voets et al., 16 Jun 2026). This decomposition separates where to intervene from how strongly to intervene.
Architecturally, ConTex comprises a temporal context encoder and a conditional encoder, followed by two heads that capture interventions in terms of temporal relevance and modification strength (Voets et al., 16 Jun 2026). The temporal encoder is instantiated with either a BiLSTM or a Temporal Convolutional Network, while FiLM conditioning modulates temporal features with target information. The forecasting objective combines a center loss, a validity loss, an 4 proximity term in input space, and a sparsity regularizer on the mask. This design makes the model target-conditioned and amortized: similar inputs and target conditions are handled by a single shared function rather than separate optimization runs.
Relative to ForecastCF, which applies gradient-based perturbations to the original time series under forecast-bound constraints (Wang et al., 2023), ConTex replaces iterative per-instance search with single-pass inference. Its reported empirical profile is explicitly computational: it reduces computational cost by at least 5–6 compared to instance-wise generation and supports real-time inference at approximately 7 seconds, while achieving state-of-the-art validity and sparse counterfactuals (Voets et al., 16 Jun 2026).
4. Plausibility, realism, and temporal coherence
Plausibility is the most divergent design axis in ConTex research. Some methods enforce it by reusing real subsequences or motifs from the target class, thereby constraining counterfactuals to observed temporal patterns (Delaney et al., 2020, Li et al., 2022). Others rely on generative priors or latent regularization so that decoded counterfactuals remain near high-density regions of the learned manifold (Lang et al., 2022, Seifi et al., 25 Sep 2025). A different line makes plausibility explicit in the optimization itself: one method minimizes a soft-DTW-based loss to the 8 nearest neighbors from the target class, combining validity, proximity, sparsity, and temporal realism directly in input space (Kostrzewa et al., 9 Mar 2026).
Domain-specific feasibility constraints form a separate strand. In large-scale multivariate SEP forecasting, physics-guided counterfactual explanations enforce channel ordering, empirical feature ranges, and temporal smoothing, and use those penalties inside a DiCE-style genetic search (Patil et al., 13 Jan 2026). This yields counterfactuals that are not only valid but physically consistent in the sense defined by the application. A plausible implication is that, for many multivariate domains, plausibility cannot be reduced to reconstruction error or nearest-neighbor similarity alone; it may require explicit structural constraints tied to the measured system.
The strongest critique of existing practice comes from the human-centered intervention perspective. The paper on temporally coherent clinical recourse argues that current time-series counterfactuals are predominantly designed with static data assumptions and are therefore insufficient for settings in which interventions unfold over time and must be causally plausible and temporally coherent (Chukwu et al., 16 Dec 2025). Its central objection is not to validity itself, but to the dominance of minimal perturbation as the design goal. This suggests a distinction between counterfactuals that are useful for model debugging and counterfactuals that are suitable for recommendation, recourse, or shared clinical decision-making.
5. Evaluation criteria and empirical findings
The evaluation vocabulary of ConTex is now relatively stable. The survey treats validity, proximity, sparsity, plausibility, diversity, stability, and actionability as the main dimensions, and extends them with time-series-aware criteria such as DTW, Fréchet distance, and segment-based compactness (Schlegel et al., 29 Mar 2026). Several papers also add contiguity and efficiency explicitly, especially for subsequence-based or multi-objective methods.
Concrete studies illustrate how differently these criteria can behave. In the interactive ECG5000 study, a 1D Conv ResNet with three residual blocks reaches train accuracy 9 and test accuracy 0, and interpretability is assessed qualitatively through data–model relationship exploration and interactive counterfactual generation rather than through formal user-study metrics (Schlegel et al., 2024). Native Guide evaluates plausibility with out-of-distribution detectors; for ECG200 under OC-SVM-MP, the OOD rate drops from 1 for w-CF to 2 for NG-CF, and for Chinatown from 3 to 4 (Delaney et al., 2020). In multivariate SEP forecasting, PGCE reports DTW 5 versus 6 for plain DiCE, sparsity 7 versus 8, and runtime 9 seconds versus 0 seconds (Patil et al., 13 Jan 2026). GenFacts, by contrast, foregrounds user studies, reporting the highest interpretability scores in a human evaluation while improving plausibility by 1 over its baselines (Seifi et al., 25 Sep 2025).
These results do not establish a single dominant objective. Instead, they show recurring trade-offs. Some methods achieve very high validity by reusing strong target-class references but sacrifice proximity or diversity; others remain very close to the original series but fail under plausibility or robustness criteria. This pattern is explicit in the survey literature and is one reason the field increasingly uses Pareto fronts, multi-objective search, or multiple simultaneous metrics rather than a single score (Schlegel et al., 29 Mar 2026).
6. Research directions and unresolved questions
Several directions recur across the literature. One is the shift from univariate classification to multivariate classification and forecasting. The interactive projection-based framework explicitly identifies multivariate extension as future work and notes that inverse reconstruction and visualization become more difficult when moving beyond single-line plots (Schlegel et al., 2024). Forecasting papers extend ConTex from label flips to desired trajectories, but they also expose the difficulty of modeling action sequences over time rather than static edits (Wang et al., 2023, Zuin et al., 1 Mar 2026).
A second direction is standardization. The survey introduces CFTS as a reference framework that includes many algorithms and evaluation metrics, with the explicit goal of standardizing evaluation and enabling practical adoption (Schlegel et al., 29 Mar 2026). This suggests that reproducibility and cross-method comparison remain open infrastructural challenges, especially because methods differ so sharply in representation space, plausibility assumptions, and optimization regime.
A third direction concerns robustness, causality, and human-centered recourse. The human-centered clinical critique shows that many current methods are highly sensitive to stochastic noise and argues for evaluation frameworks that go beyond mere prediction change without considering feasibility or actionability (Chukwu et al., 16 Dec 2025). The broader implication is that future ConTex systems may need to integrate causal structure, domain constraints, and user-facing representations simultaneously. In that trajectory, counterfactual explanations for time series would no longer be judged only by whether they flip a classifier, but by whether they correspond to sustained, purpose-driven, and temporally coherent interventions.