Skip to content

feat(engine): display batch prediction XAI in a notebook widget - #410

Merged
devanj08 merged 3 commits into
feat/training-xai-widgetfrom
feat/batch-xai-widget
Nov 21, 2026
Merged

devanj08 merged 3 commits into
feat/training-xai-widgetfrom
feat/batch-xai-widget

Conversation

@devanj08

@devanj08 devanj08 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Display saved batch-prediction explanations with prediction.visualize() or PredictionExplanations.load(path).visualize().
The widget shows the batch identity, which explanation producers ran, a cohort chart of predictions and sampled subgraphs with their recorded predictions.
It reuses the training widget's run reader, card builders and frontend, so both views share one code path.
Opening it only reads retained files and never reruns prediction or explanation generation.

What Happens and Why

A batch run with explanations=True keeps cohorts and sampled subgraphs on disk, but there is no notebook view of them.
The training widget expects targets, holdout files and a training trial, and a batch has none of these.
Opening it on a batch would show actual-value bars, ground-truth rows and evaluation tabs with nothing behind them.

The Fix

Batch explanation replay now keeps each sampled subgraph's prediction, and the widget reads samples through the explanation reader so the producer allowlist holds.
A batch loader checks that the saved explanations belong to this batch, combines attached and recorded producer status, and builds a structured identity header.
The batch view is a single panel without a tab strip, and the static snapshot draws the default cohort chart with the existing comparison bars.
HTML and PDF exports work unchanged; the HTML file is named kumo-prediction-explanations.html.

Blast Radius

Training views are unchanged on screen, and the only generation change is one extra per-sample prediction file in batch explanation output.
This stacks on the training widget PR #409; merge that first. The batch XAI API (#289) is already in that branch.

Verification

Explainability tests pass, and screenshots of six batch variants in light and dark match the previous revision except for the shown predictions and shared snapshot bars.
The browser export harness was run manually, outside CI, because it needs retained real fits; it passed in Chromium, Firefox and WebKit, including a downloaded batch HTML reopened with its selections.

Change map.

@copy-pr-bot

copy-pr-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@devanj08
devanj08 temporarily deployed to gha-kumo-workflow-tests November 19, 2026 06:50 — with GitHub Actions Inactive
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Pre-merge checks: Passed 2 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Change Map Design Review Warning Summary: I could not read the change map comment (marker <!-- kumo-pr-change-map -->, cited as 7002013964). No tool here reads PR conversation comments, and the comment is not in the repository.… Update the change map comment (<!-- kumo-pr-change-map -->) and the design as follows: - Add rows for each shared-path change listed above. For each row, state whether training output can change and why. - For card(), state whether trai…
Passed Passed checks: 2 passed

Check name Status Explanation
Pr Size Passed The PR base is feat/training-xai-widget, and its head is feat/batch-xai-widget. The local checkout has no ref for either branch. The PR's own work is the three commits on top of f2815a9, which is an …
Public Resource Access Passed The check covers only external resource references (URLs, repository locations, package sources) that this PR adds or modifies. I compared the PR's commits (454acf0 through 8482870, with 454acf0's …
Full details: Pr Size

Explanation

The PR base is feat/training-xai-widget, and its head is feat/batch-xai-widget. The local checkout has no ref for either branch. The PR's own work is the three commits on top of f2815a9, which is an ancestor of HEAD: 454acf0, 808682f and 8482870. Comparing 454acf0^ to HEAD (no merge commits in range) changes 16 files. Those 16 files are the PR's own changes, so the count is 16. That is at or below the 40-file limit, so the check passes. Caveat: the local history also holds the training-widget commits. Comparing against origin/main shows 341 files, but that is not the PR's diff. The PR is stacked on the training branch, so that count does not apply. Line counts were ignored, as the check requires.

Full details: Public Resource Access

Explanation

The check covers only external resource references (URLs, repository locations, package sources) that this PR adds or modifies. I compared the PR's commits (454acf0 through 8482870, with 454acf0's parent f2815a9 as the base) and searched every added diff line for http(s) URLs, www hosts, markdown links, script/CDN sources, import-from-URL statements, git+/git@ or registry/index references, and package-source changes. The search found none. The only matches were false positives on identifiers. The explainability.md additions contain no links, and no pyproject, package.json, requirements, or lock file changed. The contributor's PR description links to PR #409 and a change-map comment, but those appear in the PR text, not in the changed code, so they fall outside this check. The check requires no public-access verification because no external resource reference was added or modified. The PR's own changes do not add any.

Full details: Change Map Design Review

Explanation

Summary: I could not read the change map comment (marker &lt;!-- kumo-pr-change-map --&gt;, cited as 7002013964). No tool here reads PR conversation comments, and the comment is not in the repository. The standing FAIL therefore cannot be confirmed as addressed. Code-side evidence in the local checkout confirms the core concern: shared-path behavior that affects training is changed by the batch commits. Checkout identity. Local HEAD is 84828701. Its batch-specific commits are 454acf06, 808682f0, and 84828701, on top of the training widget history. The base 54048a25 and head f88b08b3 cited by the prior run are not present locally. I could not confirm that this checkout matches the current provider head. Prior claims checked. - Refuted: MAX_GROUPS and collector_card do not appear at 84828701. card() is in _subgraphs.py. Both prior claims about these symbols are wrong. - Unverified: the comment's missing stopping condition, observed failure, requirement source, and omitted shared-path rows. These depend on comment text I could not read. Shared-path changes confirmed in the batch diff (training-visible, not provably absent from the comment): 1. _subgraphs.py card() now filters categories to IDs from explanations.samples(). No run.batch guard applies to this filter. Training also calls this function. 2. _columns.py group_view adds share = entry.prediction_score / total_score if total_score else 0. The zero-total guard applies to every caller. 3. _columns.py group_view refactors series building. It also changes gap to require 'actual' in series, and it uses len(pops) for n. 4. _columns.py cohorts() adds a run.batch branch that returns analysis.cohorts or None. 5. _columns.py groups() sets the title to 'Cohorts' if run.batch else 'Column groups'. 6. _run.py adds batch and cohort_rows fields. gradient returns None for batch. explanation_coverage adds batch-only text. 7. shell.js drops the tab strip only for kind === 'prediction'. Batch cohort bound. I could not find a num_cohorts source in packages/kumo-engine at 84828701. The producer bound is unverified. Design questions (uncertain, not proven defects). The shared functions branch on run.batch in at least five places. A separate batch adapter may be simpler. The author should decide and record the reason. Basis for FAIL. The standing failure requires FAIL when its claims cannot be confirmed. The unresolved concern is that the comment must document each shared-path change above, with its training effect, plus the stopping condition, observed failure, requirement source, and cohort bound.

Resolution

Update the change map comment (&lt;!-- kumo-pr-change-map --&gt;) and the design as follows: - Add rows for each shared-path change listed above. For each row, state whether training output can change and why. - For card(), state whether training can receive a different category_samples result. Add a test, or confirm that training output is unchanged, when the filter applies. - For share, group_view, cohorts(), and groups(), state the training-visible effect of each change. - Replace the _columns.py "Emit only predictions" row with the full behavior change. - State the batch cohort count bound and its source in the producer code. - Add the observed failure and requirement source to the comment. Name the linked issue or request. - Add a stopping condition, for example: the batch loader, status, export, and browser checks in the listed tests pass. - Move widget_exports.cjs to a separate optional section. - Decide and record whether a separate batch adapter is simpler than the run.batch branches. Give the reason. - Confirm the comment matches the current PR head. Re-run the design review after the update.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@devanj08

devanj08 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Change map

Batch view built on the training widget's shared reader, cards and frontend; batch explanation replay now also keeps each sample's prediction.

File Function / scope What changed Why
packages/kumo-core/src/kumo_core/prediction_explanations.py Batch explanation replay Write each sampled subgraph's prediction sidecar alongside its graph. Batch subgraphs can show their recorded prediction.
packages/kumo-core/tests/test_prediction_explanations.py Batch replay test Assert the prediction sidecar is written. Guard the recorded prediction.
packages/kumo-engine/explainability.md Batch widget section Document batch visualize(), its views and exports. Users need to know what the batch view shows.
packages/kumo-engine/kumo/engine/_explainability/__init__.py View and card list Batch card list and export file name. Route a batch through the shared view.
packages/kumo-engine/kumo/engine/_explainability/_columns.py Cohort and group views Emit only predictions when a batch has no targets. Batches have no observed outcomes.
packages/kumo-engine/kumo/engine/_explainability/_prediction.py Batch loader Check batch identity, combine producer status, build the header. Show the right batch and which explanations exist.
packages/kumo-engine/kumo/engine/_explainability/_run.py Run loader Hold batch explanations on the shared run object. One code path for training and batch.
packages/kumo-engine/kumo/engine/_explainability/_snapshot.py Static snapshot Batch title, status lines and default cohort chart via the existing bars. Saved notebooks show batch results.
packages/kumo-engine/kumo/engine/_explainability/_subgraphs.py Subgraph card Read samples and recorded predictions through the explanation reader. Show predictions and honour the producer allowlist.
packages/kumo-engine/kumo/engine/_explainability/static/shell.js Header and tabs Structured header pairs; batch view drops the tab strip. Batch view is a single panel.
packages/kumo-engine/kumo/engine/_explainability/static/subgraphs.js Outcome strip Build outcome rows once, without ground truth for batches. Batches have no targets.
packages/kumo-engine/kumo/engine/_explainability/static/widget.css Header and status Styles for the identity grid and availability card. Batch header layout.
packages/kumo-engine/kumo/engine/explain/results.py PredictionExplanations.visualize Public entry point for saved explanations. Open a batch view from a path.
packages/kumo-engine/kumo/engine/trainer/trainer.py PredictionResult.visualize Public entry point after prediction. Open a batch view from a result.
packages/kumo-engine/test/test_prediction_explanations.py Batch widget tests Identity, status, allowlist, prediction and snapshot cases on existing fixtures. Guard batch display contracts.
packages/kumo-engine/test/widget_exports.cjs Batch export check Batch HTML round trip and print content. Exports depend on browser behaviour.

@devanj08
devanj08 force-pushed the feat/batch-xai-widget branch from af77350 to f88b08b Compare November 19, 2026 09:58
@devanj08
devanj08 temporarily deployed to gha-kumo-workflow-tests November 19, 2026 09:58 — with GitHub Actions Inactive
@devanj08
devanj08 force-pushed the feat/training-xai-widget branch 2 times, most recently from 0a99c49 to c9e52ff Compare November 20, 2026 06:46
prediction.visualize() and PredictionExplanations.load(path).visualize()
open the training widget's cohort and subgraph cards over a batch's
retained PRED-stage explanations: batch identity and row count, an
availability card per producer, a cohorts chart of predictions only,
allowlisted sampled subgraphs with their recorded predictions, a
static snapshot, and the existing HTML and PDF exports. Both widgets
share the run reader, card builders and front end; a single tab shows
without a tab strip.
The PRED replay now also writes the collector's output format, so a
sampled subgraph from trainer.predict(..., explanations=True) shows its
recorded prediction. A live manifest with a null typed field still has
its surviving model and snapshot IDs checked against the retained
record. An unreadable sampled graph no longer hides the readable ones
when the task comes from samples. Only a batch drops the tab strip, so a
training view restored from its bundle keeps its Evaluation tab. The
widget status test reuses the producer-outcome parametrization.
@devanj08
devanj08 force-pushed the feat/batch-xai-widget branch from f88b08b to 808682f Compare November 20, 2026 22:40
@devanj08
devanj08 temporarily deployed to gha-kumo-workflow-tests November 20, 2026 22:40 — with GitHub Actions Inactive
@devanj08
devanj08 marked this pull request as ready for review November 21, 2026 00:18
@Vedaant-J

Copy link
Copy Markdown
Contributor
  1. A mode flag in a shared type. Run gains batch: bool and cohort_rows, and several methods branch on if self.batch: (for example holdout coverage returns None, and the coverage text
    changes). That's fine for two run kinds, but each new kind would add more flags and branches. A small batch-run subclass, or a strategy object, would keep Run clean. It's a refactor
    suggestion, not a bug.
  2. The browser harness is extended again but still not run in CI. widget_exports.cjs gains batch export checks (+35), and the description again cites Chromium/Firefox/WebKit, which is
    the same gap as feat(engine): add training diagnostics and XAI widget #409's point 3.
  3. Two entry points: PredictionResult.visualize() and PredictionExplanations.visualize(). They make sense (live result vs loaded from a path), but the docs should say which to use when.

@devanj08
devanj08 temporarily deployed to gha-kumo-workflow-tests November 21, 2026 01:06 — with GitHub Actions Inactive
@devanj08

Copy link
Copy Markdown
Contributor Author

@Vedaant-J Addressed the two small items.

  • Browser harness: the description now says it ran manually, outside CI, because it needs retained real fits (same as feat(engine): add training diagnostics and XAI widget #409).
  • Entry points: explainability.md now says to use prediction.visualize() on a live result and PredictionExplanations.load(path).visualize() to reopen a saved run, which shows only the batch ID.

The Run batch flag versus a subclass is left as a follow-up refactor; it is fine for two run kinds.

@devanj08
devanj08 merged commit 04bf831 into feat/training-xai-widget Nov 21, 2026
113 checks passed
@devanj08
devanj08 deleted the feat/batch-xai-widget branch November 21, 2026 01:09

This branch was previously deployed

1 inactive deployment
gha-kumo-workflow-tests — 84828701 Deployed Nov 21, 2026 by devanj08 via import #2865
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants