Repository navigation
V68: counterfactuals, what would have to change - #168
Merged
Merged
Conversation
For one row of a classification, the what-if panel can now look for the smallest change that makes the inspected model answer another class: one column at a time, then two, never three. Only values the training rows hold are tried, free text is never edited, and the columns the user locks are left alone. Nothing found is an answer, given with what was tried. Measured first on the classification demos. One column is enough on most rows of three demos and two are needed on up to 69 %. Two findings shaped the panel: 8 to 60 % of the nearest changes were farther from every training row than training rows are from each other, so the search prefers a change that is not and flags the rest; and only 14 to 54 % of the other trained models followed the same change, so each answer says how many do. New how-to page in both languages, limits, reference, README, PLAN row V68, version 1.68.0. The list of proposed features is now empty. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AyBsUet8WybTG986ubroar
dapiced
marked this pull request as ready for review
November 13, 2026 19:59
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
F7, the last feature proposed. For a row typed in the what-if panel the lab said what the model predicts, what weighed (Shapley) and what happened (the glass box). A new What would have to change? button answers the fourth question: the smallest change that makes the inspected model answer another class.
A search a reader can follow, not an optimisation:
Only observed values, nothing interpolated; free text is never edited; the columns the user ticks as locked are left alone (the lab does not guess that an age cannot change). With three classes or more, one class can be asked for. Nothing found is an answer, given with what was tried. Each change has a button to load it into the form.
train/counterfactual.ts(pure):observedValues,searchCounterfactuals, andcounterfactualsFor, the worker entry.counterfactual, responsecounterfactual-result(run-derived, cleared with each new row, saved nowhere).components/insights/CounterfactualView.tsx, rendered insideWhatIfPanel; a lock checkbox beside each field.Measured before the panel
Four classification demos, three seeds, 60 test rows each, seven families.
On reviews most families find nothing: the answer is in the text. Two findings changed the design:
Known limit, stated on the panel
The lab does not know that two columns say the same thing. On titanic the forest proposed
adult_male: True to False whilesexstayedmale: each value exists, the row does not, and the far flag does not catch it. The panel and the limits page tell the user to lock or drop the duplicate.Not in this wave
Advice about the world (a counterfactual speaks of the model); more than two columns; editing free text; regression; a re-imported model; the chosen decision threshold; a published method such as DiCE.
Docs
New how-to page « find what would change a prediction » in both languages, limits, ML reference, link from « replay a prediction », README (new row, and the stale sentence listing proposals), PLAN row V68, changelog, version 1.68.0. The list of proposed features in PLAN.md is now empty.
Checks
xlsxtypes unreachable in my sandbox), format: clean.spreadsheet.test.ts(thexlsxtarball cannot be fetched in my sandbox; CI is the reference). 26 new tests; every counterfactual returned is replayed throughpredict.lab.spec.ts:31, the Excel upload, same cause). Newe2e/counterfactual.spec.tsloads a change into the form and checks the prediction shown moves, then locks that column.Generated by Claude Code