arrow_backBack to research feed
otherPublished: July 23, 2026

Beyond Sufficiency: Time Series Explanation with Counterfactual Necessity

By Hongnan Ma, Yiwei Shi, Mengyue Yang, Weiru Liu

Research TL;DR

"TimePNS uses counterfactual necessity to refine time-series explanations, suppressing spurious sufficient subsequences via a learned temporal gate."

Abstract

Faithful explanations of time-series classifiers should identify subsequences that are not only sufficient to preserve a black-box model's prediction, but also necessary for maintaining it. However, existing sufficiency-oriented methods can assign high importance to spurious subsequences that support the prediction without being essential to the model's decision. We introduce \textbf{TimePNS}, a necessity-aware framework for time-series explanation. Inspired by Pearl's counterfactual notion of necessity, TimePNS assesses whether a temporal factor is necessary by intervening on it and measuring whether the original prediction is disrupted. The framework adopts a two-stage design. Stage I learns an identifiable causal generative process together with a sufficiency-oriented explanation mask. Stage II performs counterfactual interventions on temporal factors to derive necessity signals, which supervise a temporal gate that refines the initial explanation by suppressing non-essential components and emphasizing counterfactually necessary ones. Experiments on synthetic and real-world time-series benchmarks show that TimePNS more accurately identifies decision-critical subsequences and consistently improves sufficiency-necessity trade-offs over strong baselines.

Technical Analysis & Implementation

Overview§

TimePNS is a two-stage framework for time-series explanation that goes beyond sufficiency to identify necessary subsequences for a classifier's prediction. It leverages Pearl's counterfactual notion of necessity.

Stage I: Sufficiency & Generative Modeling§

A causal generative model is learned alongside a sufficiency-oriented mask $m_s$. The generative process models the latent factors $z$ that govern the time series $x$, with an identifiable structure (e.g., via variational autoencoder). The sufficiency mask $m_s$ is trained to preserve the classifier's prediction when applied (i.e., $f(x \odot m_s) \approx f(x)$). This stage ensures the mask captures sufficient but possibly spurious patterns.

Stage II: Counterfactual Necessity & Refinement§

For a given time step $t$, the counterfactual intervention sets the value of that factor to a baseline (e.g., zero) while keeping other factors unchanged. The necessity score $N_t$ is defined as: $$ N_t = \mathbb{P}(f(\text{do}(z_t = \text{baseline})) \neq y^ \mid f(x) = y^) $$ where $\text{do}(\cdot)$ denotes the intervention. Necessity signals supervise a temporal gate $g \in [0,1]^T$ that refines the initial explanation mask $m = m_s \odot g$, suppressing non-essential components.

Implementation Details§

The architecture is: an encoder $E$ maps $x$ to latent $z$; a decoder $D$ reconstructs $x$; a sufficiency mask generator $M_s$ outputs $m_s$; a necessity estimator $N$ outputs $N_t$; a gate network $G$ outputs $g$. Training alternates between sufficiency loss (classification preservation) and necessity loss (consistency with counterfactual predictions).

PyTorch Snippet§

class TimePNS(nn.Module):
    def __init__(self, encoder, decoder, sufficiency_mask, gate):
        super().__init__()
        self.encoder = encoder
        self.decoder = decoder
        self.sufficiency_mask = sufficiency_mask
        self.gate = gate
    
    def forward(self, x, classifier):
        z = self.encoder(x)
        m_s = self.sufficiency_mask(z)
        # Stage I: sufficiency refined by gate
        y_pred = classifier(x * m_s)
        # Stage II: counterfactual intervention on each time step
        necessity_scores = []
        for t in range(x.size(1)):
            x_cf = x.clone()
            x_cf[:, t, :] = 0.0  # baseline
            with torch.no_grad():
                y_cf = classifier(x_cf)
            necessity_scores.append((y_cf != y_pred.argmax()).float())
        necessity = torch.stack(necessity_scores, dim=1)
        g = torch.sigmoid(self.gate(z))
        return m_s, g, necessity

Results§

Experiments on synthetic and real datasets (e.g., ECG, human activity) show TimePNS yields better sufficiency-necessity trade-offs and higher precision in identifying decision-critical subsequences compared to baselines like SHAP, LIME, and attention-based methods.

SHARE RESEARCH: