"An explanation that lives only in a notebook is a private opinion. An explanation a tired technician can accept or overrule at 3 a.m. is a control."
A Well-Tooled AI Agent
The Big Picture
The previous five sections built explanation methods: attribution (67.1), saliency and its traps (67.2), counterfactuals (67.3), prototypes and concepts (67.4), root-cause graphs (67.5). Each is a different research paper with a different call signature, a different tensor shape, and a different way of quietly breaking on multivariate sensor windows. This section is about the layer between those methods and a human: the libraries that give every explainer one interface, and the review loop that turns a saved attribution into a decision an operator actually makes. Two libraries anchor it. Captum is the PyTorch attribution engine (gradients, Integrated Gradients, occlusion, SHAP variants) that computes the raw signal. TSInterpret is the time-series-specific wrapper that adapts those methods to \((\text{time} \times \text{channel})\) inputs, hides the reshaping, and standardizes the plot a reviewer sees. Getting this layer right is the difference between interpretability as a paper figure and interpretability as an operational safeguard.
This section assumes you can already produce the attributions and prototypes of Sections 67.1 through 67.5, and that you understand the model-monitoring context in which review queues live (Chapter 69). Because reviewers act on flagged windows, you also need the anomaly-scoring backbone that produces the flags (Chapter 37) and the calibrated confidence that decides which flags reach a person at all (Chapter 18).
Why a tooling layer, not another method
A production sensor model rarely commits to one explainer. You want gradient-based attribution for speed on every alert, occlusion for a slower but model-agnostic second opinion, and a counterfactual when the reviewer asks "what would have made this normal?" Wiring three research repos together by hand means three tensor conventions, three normalization schemes, and three subtly different notions of what the "baseline" is. TSInterpret (Höllig, Kulbach, and Thoma, 2022) exists to remove that friction: it presents feature-attribution methods (Integrated Gradients, GradCAM, LEFTIST, TSR) and instance-based methods (counterfactuals, Native-Guide) behind one explain() call that always takes a window shaped \((\text{samples}, \text{channels}, \text{time})\) and always returns something plottable. The value is not a new algorithm; it is that every explainer becomes swappable, so a reviewer's dashboard shows the same layout whether the number underneath came from a gradient or an occlusion sweep.
Captum (Kokhlikyan et al., 2020) sits one level below as the differentiable attribution library for any PyTorch model. It supplies the mathematics: IntegratedGradients, DeepLift, GradientShap, Occlusion, and the captum.concept TCAV machinery used in Section 67.4. For a 1D sensor CNN it works out of the box because a window is just a tensor; the only care needed is choosing a physically meaningful baseline (a zeroed window implies "silence," which is wrong for a sensor with a nonzero DC bias). The division of labor is clean: Captum computes, TSInterpret adapts and standardizes, and your review UI consumes a uniform result object.
Key Insight
The reviewer is a classifier too, and a slow, expensive, distractible one. Every design choice in the tooling layer should be read as "does this reduce the reviewer's error rate or their time per case?" A consistent layout across explainers cuts their error, because they learn to read one chart instead of five. A triage order that puts the most decision-changing cases first cuts wasted time. Interpretability tooling is a human-factors problem wearing a machine-learning costume; the attribution math is necessary but it is not the product.
From attribution tensor to a review loop
A raw attribution is a tensor the same shape as the window. A review case is that tensor plus everything the human needs to rule on it: the input window, the model's prediction and calibrated confidence, the top attributed channels and time spans, one nearest historical prototype (67.4), and a field for the reviewer's verdict. The loop has four stages. Triage orders the queue, usually by a mix of predicted severity and low confidence, so scarce attention lands where a human is most likely to change the outcome. Presentation renders the case with the attribution overlaid on the signal, not as a separate heatmap the eye has to align by hand. Adjudication captures a structured verdict (confirm, override, escalate) plus a free-text reason. Feedback writes the verdict back as a label, closing the loop with the retraining triggers of Chapter 69. Skipping the feedback stage is the most common failure: teams ship a beautiful dashboard, collect thousands of expert verdicts, and throw them away.
The code below builds one review case for a sensor-window classifier using Captum's Integrated Gradients, then reduces the full attribution to the compact summary a reviewer reads first. It is the exact bridge between the method and the UI.
import torch
from captum.attr import IntegratedGradients
def build_review_case(model, window, channel_names, baseline=None):
model.eval()
window = window.unsqueeze(0) # (1, channels, time)
logits = model(window)
prob, pred = torch.softmax(logits, dim=1).max(dim=1)
if baseline is None: # per-channel mean, not zeros
baseline = window.mean(dim=2, keepdim=True).expand_as(window)
ig = IntegratedGradients(model)
attr = ig.attribute(window, baselines=baseline, target=pred, n_steps=64)
attr = attr.squeeze(0) # (channels, time)
per_channel = attr.abs().sum(dim=1) # which sensor mattered
peak_time = attr.abs().sum(dim=0).argmax() # which instant mattered
top_ch = per_channel.argmax()
return {
"prediction": pred.item(),
"confidence": round(prob.item(), 3), # gate triage on this
"top_channel": channel_names[top_ch],
"peak_time": int(peak_time),
"attribution": attr, # full map for the overlay plot
}
# usage: one call per flagged window feeds one card in the review queue
case = build_review_case(model, flagged_window, ["ax", "ay", "az", "gx", "gy", "gz"])
attribution map drives the signal overlay; confidence orders the triage queue; top_channel and peak_time are the one-line summary a reviewer reads before deciding whether to open the full plot. Note the per-channel mean baseline, which respects each sensor's DC bias instead of implying silence.The summary fields matter as much as the tensor. A reviewer scanning a queue reads "IMU alert, driven by az at t=190" and triages in a second; only on the ambiguous cases do they open the overlay. That two-tier presentation, one-line summary then full plot on demand, is what keeps a human review loop fast enough to run on a real fleet.
Library Shortcut
Implementing Integrated Gradients correctly from scratch (path integral, Riemann approximation, completeness check) is roughly 40 lines you will get subtly wrong on the baseline convergence; Captum gives it in three, with the completeness delta returned for free. Adapting five different explainers to a common \((\text{samples}, \text{channels}, \text{time})\) interface and a shared plotting call is another 200-plus lines of reshaping and normalization glue; TSInterpret's uniform explain() plus its built-in visualizers collapse that to one wrapper per method. Reach for Captum for the attribution mathematics and for TSInterpret whenever you need more than one explainer to share a dashboard.
What a reviewer actually needs on screen
A usable review card shows five things in a fixed layout: the raw signal for the driving channels, the attribution overlaid as color or shading directly on that signal, the prediction with its calibrated confidence, one nearest historical case for context, and a compact verdict control. Three rules earn their place. First, overlay, do not juxtapose: a heatmap drawn beside the signal forces the reviewer to align two x-axes by eye, and Section 67.2 already showed how easily temporal saliency misleads even when correctly aligned. Second, show confidence honestly: an uncalibrated 0.99 invites rubber-stamping, so pipe the conformal or temperature-scaled score from Chapter 18, not the raw softmax. Third, make disagreement cheap: a one-click override with a required reason produces the highest-value training labels you will ever collect, because they mark exactly where the model and an expert diverge.
Practical Example: the ICU rhythm queue
A hospital deployed an ECG arrhythmia classifier (the cardiac modeling comes from Chapter 29) with a cardiology-fellow review queue for anything flagged above a severity threshold. The first build showed a bare label and a separate saliency strip; fellows confirmed nearly everything, because verifying meant mentally aligning two plots under time pressure. The team rebuilt the card with TSInterpret: Integrated Gradients from Captum, overlaid in red directly on the lead-II trace, calibrated confidence in place of raw softmax, and one nearest confirmed prior episode beside it. Override rate on false alarms tripled, and the free-text reasons clustered into two themes, motion artifact misread as ectopy and lead-reversal, that became the next two training-data fixes. The attribution method never changed. The tooling around it turned a rubber stamp into a genuine second reader, and the review layer, not the model, is what the clinical-validation file (Chapter 34) had to document.
Wiring review into operations
The review loop is not a standalone app; it is a stage in the fleet pipeline. Alerts arrive from the monitoring layer (Chapter 69), the tooling attaches an explanation and a triage score, a human adjudicates, and the verdict flows back as a label and as an audit record. Two practices keep it honest. Cache the explanation with the alert, because recomputing an attribution days later against a since-updated model yields a different picture than the reviewer saw, and your audit trail must show what was actually on screen. And always draw the prototypes and baselines used in the tooling from the training split only, using the leakage-safe partitions of Chapter 65; a "nearest historical case" pulled from the test set has quietly leaked evaluation data into the operator's judgment.
Research Frontier
TSInterpret (Höllig et al., JMLR MLOSS 2023) and Captum (Kokhlikyan et al., 2020) remain the reference open-source stack, with Alibi and InterpretML covering adjacent model-agnostic methods. The active frontier is the review interface itself. Language-model agents (Chapter 22) are being wired to read a Captum attribution plus the top prototype and draft a natural-language rationale for the human to check, shifting the reviewer from reading heatmaps to auditing a written argument. The open risk is automation bias: a fluent LLM rationale can make a wrong attribution more persuasive, not less, so the emerging benchmarks (Section 67.7, XTSC-Bench) are beginning to score whether tooling helps a human reach the correct verdict, not merely a faster one. Human-grounded evaluation of the whole review loop, not the attribution in isolation, is the direction the field is moving.
Exercise
Take a wrist-IMU human-activity classifier and stand up a minimal review queue. (1) Use the build_review_case function to generate cases for 200 flagged windows, and order the queue by ascending calibrated confidence; report how many cases a reviewer would open at a two-tier "summary then plot" cutoff of 0.6 confidence. (2) Swap the Integrated Gradients call for Captum's Occlusion and compare the top_channel agreement rate across the two methods; where they disagree, which would you show the reviewer and why? (3) Add a required "reason" field to the override control and describe how you would route those free-text reasons into the retraining trigger of Chapter 69.
Self-Check
- Why is a per-channel mean a better Integrated Gradients baseline than an all-zeros window for most sensor signals, and what would the zero baseline silently claim?
- The tooling layer is described as reducing the reviewer's error rate or time per case. Give one concrete UI choice that targets error and one that targets time.
- A team recomputes each alert's attribution on demand instead of caching it with the alert. What audit and reproducibility problem does this create once the model is updated?
What's Next
In Section 67.7, we ask the question this whole chapter has deferred: is any of it faithful? Explanation-faithfulness benchmarks such as XTSC-Bench give a principled way to score whether an attribution reflects the model's real reasoning or just tells a plausible story, so you can choose the explainer your review tooling should trust.