Skip to content

Commit 2afdfd7

Browse files
mmschlkclaude
andauthored
Docs: the orders demo, from the Shapley values to the full decomposition (#655)
* Docs: one prediction explained at every order, from Shapley values to the Möbius transform A new demo, docs/source/demos/orders, for the hero figure of a guide: a stack of sheets, the Shapley values on top, the Shapley interactions (k-SII) of order 2, 3 and 4 below, and the Möbius transform at the bottom, each with its fit to the model (R²). Pointing at a sheet lifts it out of the stack: the sheets above move up, those below move down, and the sheet tilts towards the reader and grows. Any page embeds it with `.. shapiq-demo:: orders`. The molecule of GraphSHAP-IQ's Figure 1 (graph 71 of Mutagenicity) is explained exactly with GraphSHAPIQ for a GCN trained as in the paper (78.2% test accuracy, 7,693 evaluations): R² rises from 0.76 to 1. The photo and caption of the FIxLIP demo are explained by an illustrative toy game, with illustrative R². The scripts that computed the data are in compute/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Docs: blank sheets for the orders between, the full decomposition, and a plot of the fit by order The orders demo now shows that many orders follow order 4: blank sheets stand for the orders between it and the bottom sheet, with one row "Orders 5–9" in the ladder. The bottom sheet is the "full decomposition" (n-SII) instead of the Möbius transform, on the figure and its page, and the names of the sheets sit at their bottom corners, which always show. Below the stack, a plot of R² by order shows the fit of every order, the blank ones included. A ring on the line marks the order pointed at, in the stack or on the plot; pointing along the plot lifts the sheet of an order, or slides its blank sheet out of the stack. pack.py writes the R² and the number of values of every order for it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Docs: the full decomposition at order n, and California housing at every order The full decomposition is k-SII of order n, the number of players (30 atoms of the molecule, 8 features of a house, 74 patches and words), not of the highest order with an interaction. The plot of the fit by order shows every order up to that one and n, with a break in its axis where the orders between are left out (they all equal the full decomposition), and the row of the blank sheets names all orders between 4 and n. Two new examples, explained exactly with the interventional TreeExplainer (Woodelf) for an XGBoost model of depth 7 trained on California housing, whose interactions stop at order 7: one house in Los Angeles, whose Shapley values fit with R² = 0.30 and its pairs with 0.995 (latitude × longitude), drawn as its features on a circle; and 150 houses as a heatmap, a column per house sorted by its prediction and a row per feature or group, with a mean R² from 0.77 to 1. housing.py computes them, pack.py packs them. R² reads 1.00 only where the fit is exact, and "> 0.999" just below. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Docs: the house as a tree, the real number of players, and an icon of the model The house of the orders demo is drawn as a tree that grows one level per order: its features on top, and every group of k features at level k, joined to its features, so that the full decomposition is a tree of depth 7, as deep as the model's trees. Every level shows its strongest groups. The full decomposition's tag and the last tick of the plot show the number of players (30-SII, 8-SII, 74-SII) instead of n, and the captions say "all 30 atoms" instead of "n = 30". A badge under the examples names the kind of model, with an icon: a decision tree for the XGBoost model, a graph for the GCN, and a black box (an isometric cube, black in both themes) for SigLIP 2; the examples carry the same icons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * WIP Docs: compute the FIxLIP example of the orders demo for real fixlip.py no longer defines a toy game: it evaluates the FIxLIP demo's game of SigLIP 2, the elephant and its caption (imported from the demo's scripts) on the 5,000 coalitions ProxySHAP samples and 512 held-out ones, caching every evaluation, and reads the full decomposition of ProxySHAP's proxy without adjustment (k-SII of the proxy's depth), from which every order follows; every order is scored on the held-out coalitions against the model itself. pack.py takes the budget and the similarity from its result. The demo's data (data.js) and texts still show the illustrative values: they follow once the computation has run. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Docs: the FIxLIP example of the orders demo, computed for real with ProxySHAP How SigLIP 2 matches the FIxLIP demo's elephant and caption is no longer an illustrative toy game: fixlip.py evaluated the demo's game on the 5,000 coalitions ProxySHAP samples (and 512 held out, kept in results/), and ProxySHAP without adjustment reads the full decomposition of its XGBoost proxy, of depth 6 (the best of 3 to 8 in a 5-fold cross-validation), from which every order of k-SII follows; its 2-SII equals ProxySHAP's own to 4e-15. On the held-out coalitions, every player present with probability 1/2 as for the other examples, R² goes from 0.55 (Shapley values) over 0.52, 0.56 to 0.88 (order 4) and 0.89 for the full decomposition, which reproduces the proxy, not the black box, exactly. The captions, the badge (ProxySHAP from 5,000 coalitions), the page (with the call of ProxySHAP), the README and the changelog say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Sample the FIxLIP example's coalitions as FIxLIP does, 10,000 of them ProxySHAP now fits its proxy to 10,000 coalitions in which every player is present with probability 1/2 (as in FIxLIP, and as every order is scored), instead of 5,000 of uniformly random size. The fit rises monotonically: R^2 0.54 (Shapley values), 0.93, 0.95, 0.96, up to 0.96 for the full decomposition of the proxy (before: 0.55, 0.52, 0.56, 0.88, up to 0.89). Captions, page, README and changelog follow the new values. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Give the orders demo's examples equally deep stacks of blank sheets Every example now has six blank sheets where it skips that many orders, not one per order of its plot: SigLIP's proxy stops at depth 6, so its stack showed two blank sheets for orders 5 to 73, against the molecule's six. The extra sheets stand for the orders after the proxy's depth, which equal the full decomposition: pointing at one gives its R^2 and marks it on the dashed part of the plot. The molecule (orders 5 to 10) and the houses (5 to 7, all there are below n = 8) are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Draw the orders demo's molecule as shapiq's SI graph plot does The molecule's sheets now show the 300 strongest groups (was 72), most of them a faint haze around the strong ones, drawn as si_graph_plot draws them with node_size_scaling=0.5 and size_factor=2: every value as wide and as opaque as its share of the sheet's largest, main effects as a disc around the atom no wider than a group of the same value, over the sheet's color. The centers of groups of three or more atoms are now where si_graph_plot places them: pack.py runs its spring layout (atoms fixed, every center pulled to its atoms by its value) and stores them in data.js. The centroid, which the demo used, falls onto the middle atom of an atom and its neighbors, so that the strongest groups ran along the bonds. The photo-and-caption example keeps its 72 groups and its look. The fallback image shows the new molecule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Calm the orders demo's switch between examples; slide the example pill Choosing an example no longer opens the new stack out of a pile: the stack, its fits, the plot and the caption fade out, and the example chosen fades in at rest (demo.js waits for the fade out to end). Without motion, it shows at once. The demo fades in once on load, too. The example chosen sits in a pill that slides to the next one chosen: a copy of the examples in the chosen colors, cut to the pill, so that every label turns exactly as the pill passes over it. The examples brighten on hover and give a little when pressed. The hint "Point at a sheet, or along the plot." is gone. The photo-and-caption example is drawn as the molecule now: its 300 strongest groups per sheet, every value, patch and word as wide and as opaque as its share of the sheet's largest value. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a gentler scale of fit, and a sliding variant of pointing The verdict beside every sheet's R² now reads poor below 0.6, workable below 0.8, good below 0.95, very good above, and exact at 1: the average fit of the 150 houses' Shapley values, 0.77, is workable, not poor. With data-lift="slide" on the demo, the sheet pointed at slides out of the stack to the left as it lies, without tilting or growing, over the others, which stay where they are. The sheets are smaller to leave the room for it. The demo follows the attribute while it runs; by default, the sheet still lifts out of the stack. The fallback image shows the new verdicts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: end the houses' stacks at 7-SII; keep a slid sheet's place For the trees of depth 7, k-SII of order 7 is already the full decomposition, and exact: the houses' stacks and plots now end there (7-SII) instead of at 8-SII, so their blank sheets stand for orders 5 and 6. The molecule keeps its 30-SII and SigLIP its 74-SII. pack.py takes the order of the full decomposition per example, and the captions count the features apart from it. In the sliding variant, the sheet pointed at keeps its place in the stack: the sheets above it still lie over it as it slides out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: trees of depth 5, exact at 5-SII; steady sliding The XGBoost model of the houses now has depth 5 (test R² 0.848, was 0.852 at depth 7): its 5-SII is the full decomposition and exact, so the houses' stacks end at 5-SII without blank sheets. housing.py's rule now picks house 837 near downtown Los Angeles, whose Shapley values fit with R² 0.31, then 0.995, then exactly; the 150 houses' Shapley values fit with 0.83 on average. Captions, the model's badge, the page, the README and the changelog follow; the house's caption of order 3 names the groups it has now. Only an R² of 1 (to the data's six decimals) reads 1.00 and exact: the houses' 4-SII, at 0.999999, reads > 0.999, very good. In the sliding variant, the sheets count where they lie at rest while one is slid out, and the one slid out also where it shows: a sheet sliding away from under the pointer no longer hands it to the sheet below and comes back for it, which made it jitter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: explain house 837 with TabPFN too (work in progress) house_tabpfn.py, the explanation of the house of housing.py by TabPFN (a black box, with shapiq's TabPFNImputer), follows housing.py's switch to depth 5 and its house, 837. The script is still being run; the demo does not show TabPFN yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: slide out by default, chips on touch screens, complexity cues Pointing at a sheet now slides it out of the stack by default (it keeps its place in the stack); data-lift="lift" on the demo lifts it out as before. Under the stack, a chip for every sheet (SV, 2-SII, ..., the full decomposition) brings it out with a tap, where nothing hovers (touch screens) or the room is short; a second tap puts it back. An arrow down the side of the stack, and one along the plot's axis between "order" and "full decomposition", both labeled "more complex", say that the explanations grow more complex from order to order. The page, the changelog and the fallback image follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: TabPFN's runtimes in house_tabpfn.py (work in progress) The script explained house 837 with TabPFN: about six seconds per prediction, about 25 minutes for the house's coalitions. The demo does not show TabPFN yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: rows stay put while a sheet slides; names on the sheets While a sheet slides out, the rows of the ladder (its name, bar and R²) stay where they are: the sheet slides straight to the side, without the small drop it had, and the row of the blank sheets stays beside the middle one. The top sheet reads "Shapley values (SV)" and the bottom one "Full decomposition (n-SII)", with n the example's order of it. The examples are named "All houses" (was "150 houses") and "Describing Images" (was "Photo and caption"), and the page's paragraphs on them follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the same house, valued by TabPFN, a black box A new example, "One house, TabPFN", explains the house of the XGBoost model with TabPFN, exactly from all 256 subsets of its 8 features with shapiq's TabPFNImputer, which removes an absent feature from TabPFN's context instead of imputing it. TabPFN has no depth that would cap its interactions: R² rises from 0.05 for the Shapley values to 0.82 with pairs (latitude with longitude, the income with the rooms), and only 8-SII, the full decomposition, is exact, where the trees of depth 5 are exact at 5-SII. house_tabpfn.py lets TabPFN make one pass without randomness: its default ensemble shuffles the features anew for every subset, a noise that piles up in the high orders of the explanation. This TabPFN predicts the test houses with R² 0.846 (the ensemble: 0.818), in an eighth of the time. The example buttons are a little narrower, so that the five fit in a row at the docs' width. The page, the README and the changelog describe the example; the page shows how it was computed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a vertical slider of the orders on the complexity arrow The arrow beside the stack ("more complex") is now a slider, in a column of its own left of the stack: a tick at every sheet and a smaller one at every blank sheet, and a handle that rests above the top sheet. Dragging it (by mouse or touch) or pressing a tick brings out the sheet there, which stays out; the arrow keys step through the orders. It replaces the chips under the stack on touch screens, in a design of its own rather than the examples' pills. The page, the changelog and the fallback image follow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the slider's handle stays on its tick while hovered The handle grows a little while the pointer is over the slider (scale), and its place was a transform, which that scale multiplied too: hovered, the handle sat up to 46 pixels below its tick, the further the lower. It is now placed by translate, which the scale leaves alone. Pressing the slider focuses the handle again, without the ring of keyboard focus, so that the arrow keys go on from there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: FSII and the Shapley distribution (work in progress) The scripts move from k-SII to FSII, scored on coalitions drawn from the Shapley distribution (faithfulness.py, and fixlip.py so far). They are still being changed and run; the demo's data has not changed yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: no captions; the plot of the fit by order in the middle The captions beside the plot, which interpreted every sheet and every example, are gone, with the code that wrote them; the plot of the fit by order stands alone under the stack, in the middle, its title above it. The ladder's rows and the slider still name the sheet pointed at. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: FSII in the house scripts (work in progress) housing.py and house_tabpfn.py move to FSII, scored on the Shapley distribution. They are still being changed and run; the demo's data has not changed yet. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: FSII in molecule.py (work in progress) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a more visible arrow of complexity The slider's line beside the stack is twice as wide and darkens downwards to a larger, darker arrowhead; its ticks and its label "more complex" are darker too, and the arrow along the plot's axis matches. The fallback image follows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: FSII in faithfulness.py and pack.py (work in progress) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: FSII in the compute README (work in progress) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: bars of one width; the faithfulness plot with labeled axes Every row of the ladder gives its bar, its R² and its verdict the same width, so that the bars line up and are as long in every row and every example ("very good" no longer takes room from its bar); the ladder is a little wider for it. On narrow screens, without verdicts, the bars share what is left. The plot is titled "Faithfulness by order", with its axes labeled: "order of interaction" under the orders and "faithfulness (R²)" along the side. The arrow "more complex" runs under the axis's label, and "full decomposition" names the last point above it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the faithfulness plot's title over its area The title "Faithfulness by order" stands in the middle of the plot's area, as the label of its axis does, not in the middle of the figure with the ticks: it takes the plot's margins. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: "R² 0.76, workable" in one phrase The R² and its verdict beside every sheet read as one phrase, with a comma, instead of in columns of their own, which left gaps after short values. The bars keep one width; where the verdict is hidden, so is its comma. The fallback image follows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: FSII in fixlip.py (work in progress) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: FSII at every order, faithful under the Shapley distribution Every sheet below the Shapley values now holds FSII, the Faithful Shapley Interactions, instead of k-SII, and every R² is measured on coalitions drawn from the distribution of the Shapley values (sizes s weighted by 1/(s(n-s)), the weights of KernelSHAP), the distribution under which FSII of every order is the best fit of its order: the faithfulness never falls from one order to the next (exactly, for all but SigLIP 2's proxy, which stays flat from order 3). FSII of order 1 is the Shapley values; FSII of the highest order is the full decomposition. faithfulness.py holds the Shapley distribution, the weighted R² and FSII for every script. molecule.py, housing.py and house_tabpfn.py convert their exact full decompositions into FSII; fixlip.py draws ProxySHAP's 10,000 coalitions and its 512 held-out ones from the Shapley distribution. housing.py keeps house 837 (its Shapley values fit worse than those of 96 % of the houses near downtown). pack.py passes the index on, and R² to nine decimals, so that only an exact order reads exact. The sheets are tagged 2-FSII and so on; the page, the README and the changelog follow with the new numbers: the Shapley values fit the molecule with R² 0.98, the house with 0.39, TabPFN with 0.25, the houses with 0.86 on average and SigLIP 2 with 0.91. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: R² beyond coalition size, and an estimation tax band (work in progress) Faithfulness weighs an explanation's errors against the spread of the model's output among coalitions of the same size; the plot shades what an estimated full decomposition falls short of 1. The data is being recomputed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: R² beyond coalition size, and the estimation tax Under the Shapley distribution, a coalition's value mostly follows how many players it holds: plain R² credited every explanation with that trend (for the molecule, size alone explains 98 % of the spread, and the Shapley values reached R² 0.98). Every order is now scored by its R² beyond size: the weighted errors against the spread of the model's output among coalitions of the same size. FSII of every order is still the best fit of its order, and the fit still never falls from one order to the next. The Shapley values now fit the molecule with R² 0.36, the house with 0.36, TabPFN with 0.06, all houses with 0.83 on average, and SigLIP 2 with 0.48; for SigLIP 2, the sizes' means come from all coalitions of the run, as its 512 held-out ones are too few for 73 sizes. Where the full decomposition is estimated (SigLIP 2's, from a proxy fit to 10,000 coalitions), the plot shades what its R² falls short of 1, the estimation tax (0.19: half the proxy's error, half the constant by which ProxySHAP anchors the explanation at the game's empty value). The band's label sits inside it, or above the plot where it is too thin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: harmonize with probly's Milton demo, slide-out only Where the orders demo has the same kind of element as the Milton demo, it now follows it: one set of tokens on the root that maps the docs' (ease, duration, the glide of what moves a distance, the control's height), options as high as a control of 2.35rem, the pill gliding in 380 ms, presses at 0.96, solid focus rings, the switch tightening below 40rem, the examples fading in over 420 ms and the model line entering as Milton's panel, [hidden] kept hidden, and no motion at all for reduced motion. It stays frameless, a hero illustration on the page. The lift-and-tilt hover is gone: a sheet pointed at slides out of the stack, as before by default, and the poses, strips and rows that only lifting used are removed. On SigLIP 2's plot, the note on the full decomposition sits on the estimation tax's line, at the other end of the band, with a halo. The demos' Sphinx extension takes the fixes made for Milton: assets copied on env-updated (so their links carry Sphinx's checksums), a data-version attribute (the checksum of data.js, which both demos' scripts load with ?v=), note_dependency on the assets, and no demo outside HTML. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: no ladder on narrow screens, larger sheets instead Below a stage of 560px, the rows of fits beside the stack are hidden and their room goes to the sheets, about half again as wide on a phone; the plot below the stack still shows the fit of every order, and the order of a sheet tapped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a shorter plot, and on narrow screens its verdicts The plot's axis is 94px high instead of 118px, so that the demo fits a phone's screen better. On narrow screens, which have no ladder, the R^2 the plot shows at the order pointed at has its verdict in a line under it; low on the plot, both lines stay above the axis. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: SigLIP 2 through a proxy of depth 8, with its own empty value (work in progress) fixlip.py fits the proxy with ProxySHAP and reads its Moebius transform off its trees with InterventionalTreeSHAPIQ, keeping the proxy's own value of the empty coalition; faithfulness.predictions sums the groups in chunks; pack.py takes the counts of orders whose values are left out. The data is being recomputed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: SigLIP 2 at the proxy's best depth, with its own empty value The proxy's depth stays 6, now chosen as the rest is scored: the best of 4 to 12 in a 5-fold cross-validation on its 10,000 coalitions by R^2 beyond size (0.917; 0.914 at depth 8). The explanation keeps the proxy's own value of the empty coalition (-0.008), read off its trees with InterventionalTreeSHAPIQ, so every order is FSII of the proxy and the full decomposition the proxy itself: its R^2 rises from 0.68 to 0.91 at order 4 and stays there (within 0.001, the chance of 512 held-out coalitions), and the estimation tax is the proxy's own error, 0.09. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: fixes from a review - The demo is its own stacking context, so its sheets and slider no longer paint over Furo's sticky header or take taps meant for its navigation drawer on phones. - Pointing at anything while an example fades out no longer throws and leaves the demo invisible: nothing is pointed at during a switch, and a new example shows at rest. - The extension declares an env_version, so doctrees pickled before the data-version attribute are read again instead of crashing incremental builds; it reads the attribute with a default too. - The TabPFN snippet runs: TabPFNImputer needs a predict_function, and the model is the script's (the v2 weights, random_state, the pretraining limits lifted). - If the demo cannot start, it shows the static figure, kept before the demo replaces it. - The plot's verdict line follows the narrow breakpoint on resize; a row is aria-pressed only when its sheet is pinned; the marker's value has its own class (the axis labels keep their look), with the page's halo; clip ids are unique across demos; a mouse click on the plot after a dragging touch counts; the slider takes the main button only; the narrow switch padding applies (it came before the base rule). - Dead CSS and attributes removed, stale comments fixed, and the page and changelog say the fit never falls for a model explained exactly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: switching examples about seven times faster on a phone Profiled on a phone-sized page with the CPU throttled four times, the longest task when switching to the molecule or to the photo was about 750 ms; now it is about 100 to 140 ms, and dragging the slider has no long tasks left. - Every interaction is one path with fill-opacity instead of a group with opacity holding a path per player and a circle per end: about 1,800 elements per example instead of about 9,600, and no layer per interaction to paint. Its discs run clockwise as its bowties, so that where they overlap the path is filled once, as the group was. - Every example's sheets are drawn once and kept; the examples not shown yet are drawn while the page is idle, a sheet at a time. - A new example's sheets join the stack only once placed, so that their faces are styled and laid out once, not twice. - Rounding uses Math.round instead of toFixed, about 15 times faster. - The faces, and the stack, rows and plot that fade, keep layers of their own, so that stepping back and fading neither start nor end with a repaint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the area under the plot's line fades toward the axis The flat wash under the line (its ink at 6%) is now a gradient of the same ink, 16% where the line runs highest down to 1% at the axis, in light and dark mode alike. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a stepper through the examples on phones; more faithful down the arrow Where the five examples would not fit in a row (a demo narrower than 45rem), the switch, which wrapped into a box of rows, gives way to a stepper: the example shown, with its icon and its place among the examples, between a button to the previous and one to the next, wrapping around; it comes in from the side it was stepped to. A swipe sideways across the stack steps too, and is no tap on a sheet; the page still scrolls with a swipe up or down. The arrow beside the stack now reads "more complex, more faithful". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a shorter plot without a title, and dots under the stack on phones The plot's axis is 75px high, 0.8 of before, and its title is gone (its accessible name keeps the words: faithfulness by order). Where the stepper shows, a dot for every example sits under the stack, the one shown dark, as under a post of several images. The placeholder that keeps the demo's room while it loads follows its new heights (44.5rem, 37.5rem on phones; it was 58rem). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the arrow reads "more complex and more faithful" Upright, with only "complex" and "faithful" in italics. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: swipe the stack between examples on touch screens The swipe did not work on iPhones: Safari knows no pinch-zoom in touch-action, dropped the whole declaration, and took every sideways drag for itself. The stage now declares pan-y first, which Safari keeps. On a touch screen, the stack follows the finger sideways and fades as it goes; past a third of its width, or flicked, it leaves to that side and the next example comes in from the other, else it springs back. The stepper's arrows slide the stack the same way, a shorter distance. The stack sits in a window that starts at the slider's column, so it goes out of view there, not under the slider, and never widens the page. A tap on the stack no longer brings out a sheet on a touch screen (the slider and the plot do), and hover styles apply only where there is a hover. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a comma between the model and how it was explained; TabPFN unqualified The badge reads e.g. "GCN with 2 layers, exact with GraphSHAP-IQ" instead of separating the two with a dot, and the TabPFN example names its model just "TabPFN". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the swipe holds on iOS, and a natural swipe is enough The swipe listened to pointer events, which cannot keep a drag from the browser: on iOS, a sideways drag across the stack went a few pixels and was then cancelled, as Safari took it over. It now listens to touch events and, once a drag goes sideways (after 4 pixels), prevents the touchmove's default, so the stack keeps following the finger; a drag that goes up or down first still scrolls the page. A swipe also counts sooner: past a fifth of the stack's width (it was a third), or as a flick, now measured over the last 100 ms of the drag (at 0.3 px/ms) instead of over the whole of it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: stepping swipes the stack, the plot and the model line On a phone, the plot and the model line under the stepper now go with the stack: they follow a finger swiping the stack, and stepping to another example (by a swipe or the stepper's arrows) swipes all three: they leave to the side, out of view, speeding up and keeping their opacity, from where the finger let go, and the new example comes in from the other side, slowing down. Each is clipped at the demo's edge, so the page never widens. The model line skips its own entrance when it is swiped in, and on wide screens the switch still fades the example in place. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a tap on a sheet brings it out on touch screens again A tap on the stack slides the sheet tapped out of it again, as it does with a mouse; a swipe sideways still steps through the examples, and the click that may follow the end of a swipe is not taken for a tap. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a projector view, the explanations as foils on the input A second view of the demo, chosen by data-view="projector" on its container (the docs keep the stack): the example's input lies as a card on the glass plate of an overhead projector (the molecule's atoms and bonds, the house's features and values, the houses' predictions, the photo and its caption), and every explanation is a transparent foil, its marks only, in a tray beside the card (below it on phones, with a caption each). Pointing at a foil, its row, or its order on the plot lays it onto the card, a little askew in the tray and settling flat on the glass, its ink multiplied over the card (screened on a dark one) so that the input shows through, and the card lies in the lamp's light; a click pins it, a click on the card takes it back. The blank foil stands for the orders between. The rows, the plot, the stepper, the dots and the swipe work as in the stack. The faces draw a layer each: all of it for a sheet of the stack, as before, or its input or its marks for the projector. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a hologram view instead of the projector The projector view gives way to a hologram (data-view="hologram"; the docs keep the stack). The example's input lies on a card at the bottom, and every explanation is a see-through layer above it, with its marks only: film with scan lines and a glowing edge. At rest, the layers lie on the card, the top one showing its marks on the input. While the pointer is over the stage, or after a tap on the card, they float off it, apart, peeling off the top one first and each floating a little; the card then shows the bare input. The layer pointed at (by hovering it, its row, the slider or the plot) lights up as the others dim, and its light falls down onto the card, which wears its marks, multiplied on a light card and screened on a dark one. The rows and the slider keep to where the layers float; the plot, the stepper and the swipe work as in the stack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: add a mechanism view, the full decomposition below the input A third view beside the stack and the hologram (data-view="mechanism"): the explanations float above the input card as in the hologram, but the full decomposition lies beneath the card, in amber, as the mechanism under it all. It hides under the card at rest, with an edge showing; pointed at, its light rises into the card. The slider becomes a depth gauge: the arrow ends at the input's surface, and a dashed line leads down to the mechanism. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: exploded view, calm tone, and what every order adds - The exploded view (data-view="exploded"): the mechanism as a technical drawing. At rest, the parts put together are a block cut away at the front, the mechanism showing inside, the cut's faces hatched; open, they come apart along their axis with chain lines through their corners, and the rows become a parts list (numbered balloons, how many values each part has); the slider is drawn as a dimension. - data-tone="calm" tones the hologram and the mechanism down to paper: no glow, scan lines or floating. - data-show="delta": every sheet shows what it adds to the one above it (its values less theirs, at its own scale), its row what its R^2 gains, and the plot a bar per order for the gain; in the hologram views the card wears what the layers add up to. pack.py writes these deltas from the full explanations. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the mechanism apart from the explanations, and smaller deltas - data-full="both" (in the mechanism and the exploded view): the full decomposition is also the last explanation above the input, as in the stack, and below the input lies, apart, the mechanism they explain, the model itself. Its row tells how many terms it has, of the 2^n it could have; where the full decomposition is estimated, the mechanism shows blurred, as only an estimate shows it. - What every sheet adds keeps its 150 strongest interactions (300 before): data.js shrinks from 221 to 189 kB. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the layer pointed at shows through the calm layers above it In the calm tone and the exploded view, the layers are paper: the paper of the layers above the one pointed at veiled it, which so looked no brighter. While a layer is pointed at, the others' paper now thins as their marks fade. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: drop the hologram view The mechanism and the exploded view build on the hologram's floating layers, so those stay; the hologram itself, with its card at the bottom and the full decomposition as a layer above it, is gone. Its names go with it: the views with floating layers are layered(), their root class orders-demo-floating (orders-demo-open while open, orders-demo-top for the layer on the card at rest), and their film's tokens --orders-layer-*. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the plan above the stack, and the mechanism always apart - Above the stack, the plan: the example seen from above, flat, its input with the explanation pointed at on it (at rest, the Shapley values), and beside it, in words, what that explanation shows, how well it fits (and, showing what every order adds, what it gains), and how its marks read. It shows the full decomposition for the mechanism and for an order between that equals it, and the input alone for another. It fades and swipes with the example, in a window of its own. - The mechanism and the exploded view always show the full decomposition as the last explanation above the input, and the mechanism apart below it: the data-full switch is gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the plan tells the problem, a button per order, and blank sheets on hover - The plan opens with the problem as machine learning draws it: the input x, the model f (its kind, its details and how well it does on test data) and its prediction f(x), three boxes with arrows between them. The model's badge under the examples, which it repeats, is gone. pack.py writes every example's problem in words. - Under it, "Why f(x)? Explained at order", a button for every order (and the mechanism), which points at its sheet when hovered or focused and pins it when tapped; the order shown is outlined, the one pointed at filled. The words add how the explanation was computed and that its values add up to f(x) - f(empty), with what f(empty) is. - The blank sheets of the orders between come out when pointed at also while a sheet is slid out: coming down the stack from order 4, they stayed in, and order 4 out. - Tapping what is pointed at already pins it, and its row and button now say so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: rename the estimation tax to the estimation gap What the fit of an estimated full decomposition falls short of 1 is the estimation gap: in the plot's band and label, the plan's words, the docs, the compute scripts and the changelog, and in the names of its color and classes (--orders-gap, orders-demo-plot-gap). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: four more designs of the problem, to choose from The problem above the stack follows data-problem on the demo: - boxes (the default): the input x, the model f and the prediction f(x); - equation: f, named by its model, of the input itself in parentheses, equals the prediction, and under it what every term is; - sentence: the problem in words, its model, input and prediction marked as with a highlighter, each with its symbol; - wire: the input, a wire into the model's dark chip and out to the prediction's display, its dashes flowing from x to f(x); - number line: the model's scale from f of the empty input to f(x), the span the explanation splits up, red where the input raises f and blue where it lowers it (of many houses, a tick at each prediction). A house shows as a table of its features, many houses as a table of houses by features (on a phone, or inline, as the glyph of a table). pack.py writes what the designs need: the model's name, f(empty) and f(x) as numbers with their unit and a few words each, and the problem as a sentence. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the problem as a wire, its chip opened by the explanation The problem above the stack is the wire alone (the boxes, the equation, the sentence and the number line are gone, with what pack.py wrote for them): the input wired through the model's chip to the prediction, the chip in the middle of the plan, which is centered. - The chip is black for a black box (TabPFN, SigLIP 2), gray for a model whose structure the explanation uses (the GCN, the tree ensemble). - The prediction is in the red of what raises it. - The explanation falls out of the chip, a light from its bottom corners onto the card below, which is lit while an explanation is pointed at; and the chip clears as far as that explanation fits, its R^2: at the full decomposition, all the way where it is exact, and to 0.91 for SigLIP 2, its estimation gap. On a dark page, it clears to light glass. - The card says little: the order and what it is in a few words ("groups of up to 2 atoms"), its R^2, how it was computed, and the colors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: explain on a click on the model, and no closing between zones - With data-reveal="click" on the demo, it starts with the problem alone: the input, the model's chip and the prediction. The chip calls (a ring going out of it, a tab "Explain" under it), and a click on it, or Enter, explains it: the light pours out of the chip, the card materializes, the sheets drop in one after the other, then the rows and the slider, and the plot draws itself from left to right. Once explained, every example is. - The pointer going from the plan's card to the stage to the plot no longer sends everything back to rest and out again: the floating layers stay open, and what was pointed at stays out, until the pointer has left all three for a moment. - The floating layers' rhythm is set only while they float, so that their entrance can be timed one after the other. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the mechanism view is the unfolded view, and unfolds on explaining - The view of floating layers is now data-view="unfolded" (it was "mechanism"; the mechanism stays what lies below the input). - In it, a click on the model's chip that explains the example also unfolds the layers, shortly after they have come in: they float apart as for the pointer, and rest again once the pointer has been over them and left, or a tap on the card closes them. - The exploded view is gone: its cutaway, assembly lines, parts list and drawing style, and their colors. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the problem's three boxes as tall as one another, without pins The input, the model's chip and the prediction are now boxes of one height (6.6rem, on a phone 5.2rem), their middles on the wires' line, each with its symbol in its corner; the input is drawn as large as its box allows, and a house's table or its glyph has no frame of its own inside it. The chip's pins, a picture of a chip that meant nothing in the data, are gone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: explain by default, built from the top down; a board that stays - The demo starts with the problem alone, by default (data-reveal="open" starts it explained). A click on the chip builds the explanation below it from the top down: a line runs down from the chip, and every part comes as it passes, the card unveiled downwards, the sheets one after the other with their rows, the slider, and the plot, drawn from left to right. - The problem stays as the examples change, swiped or chosen: its frames (the input's, the chip, the prediction's) keep their places and sizes, and what they show flips in as on a board of departures, its words running through letters before they settle; the card under it flips too. Only the stack and the plot are swiped. - In the unfolded view, the layers unfold once, for good: after the model was clicked to explain it, once they have come in and the stage is in view (on a phone, once scrolled to), or tapped at rest. Swiped or chosen, the next example shows unfolded at once, and the pointer no longer folds and unfolds them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the estimated mechanism blurred again, wherever it shows Removing the exploded view had taken with it the rules that blur the mechanism where only an estimate shows it (SigLIP 2), and those of the mechanism's row (its size, 2 to the n). They are back, and the blur now reaches wherever that mechanism shows: its layer below the input, its light on the input's card, and the plan's face of it when it is pointed at. The exact examples, and the full decomposition as an explanation, stay sharp. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the problem's three boxes of one size, their faces fitted The input's box, the model's chip and the prediction's box now have one size for all three (11.5 by 6.6rem; on a phone, 6.1 by 5.2rem). What one shows is scaled down about its middle where it would not fit (a house's table, a long prediction, the chip's words on a phone), fitted again as it changes, as the plan's width does, and once the fonts have loaded. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: fit a part's face by a name of its own The function that scales a part's face to its box was called fit, which the plan's words shadow with their fit (its R^2): pointing at an order threw. It is fitPart now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: de-clutter the card, drop the deltas, plot beside the sheets - Remove the delta sheets (data-show="delta") and their data: the stack shows whole explanations only; data.js is back to 117 KB. - The explanation card loses its order buttons and its hint, and is centred under the chip. - The light out of the chip meets the chip's and the card's rounded corners halfway round them, not short of them. - The wire's dashes flow from a 12px tile, so the first dash no longer jumps when the next one comes in. - New data-plot="beside": the R² plot stands upright where the rows were, every order at its sheet's height (unfolded, on down to the mechanism at R² 1), and the card carries what the rows said: the sheet's name, its bar, R² and verdict. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: narrow the plot beside the sheets to 0.6 of its width The upright plot's column shrinks from at most 200px (118px on narrow screens) to 120px (71px), and the sheets take the room. Its axis is named "R²" where it is too narrow for "faithfulness (R²)", and the ring's value goes right of it only where it fits on the stage. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the plot beside the sheets ends at the last explanation Unfolded, the upright plot no longer runs on to the mechanism: its line, grid and gap band end at the full decomposition, and the mechanism's row goes with its point. The axis is named "faithfulness (R²)" again: over the plot's middle where it fits, else ending at the plot's right. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the card stays in place, the plots keep their frames - The explanation card no longer moves or resizes between examples or between the explanations pointed at: its words take a column of fixed width, as tall as the most it can say in any example (measured out of view for the column's width, the view and the plot's place). - Both plots keep their frame as the examples change: the grid, the ticks of R² (which flip to the next example's) and the names of the axes stay; only what they plot fades, and below the stack slides with the swipe, in a window right of the axis. Beside the sheets, the frame's rules stretch or shrink to the next example's stack. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: calmer unfolded layers, a tab bar as wide as the problem - In the calm tone, the layers' paper is near opaque (0.92, was 0.55): what a layer covers of the layers below barely shows through at rest; pointed at, the others' paper still thins. - The examples' bar spans the problem below it, from the input's left edge to the prediction's right one, its tabs sharing the width. On a phone the three boxes shrink a little where they would overhang it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: beside the unfolded sheets, the slider ends at the explanations With the plot beside the sheets, the unfolded view's slider goes through the explanations only, as the plot does: its arrow ends at the full decomposition, without the input's surface or the dashed line down to the mechanism. The input and the mechanism are named instead right of their sheets, under the plot, where the rows' lines lead to them (the mechanism's name still points at it). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: in the calm tone, the mechanism pointed at casts a box too Pointed at, the mechanism rises to the card in the calm tone as in the glow: a wash of its amber paper between them (it had none, the calm mechanism having no glow) and the box's edges drawn solid, not dashed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: one tone for the unfolded view, one place for the plot - The calm tone is the unfolded view's own: its layers are paper with an edge below, near opaque, and still; the mechanism amber paper, which casts a box of light up to the card. The glowing film, its scan lines, its floating and data-tone go. - The plot of the fit stands upright beside the sheets, always: the plot below the stack, the rows' bars and scores, the row of the blank sheets and data-plot go. The rows keep their lines to the plot and their buttons for the keyboard; unfolded, the input's and the mechanism's name them, and the slider goes through the explanations only (its depth gauge down to the mechanism goes too). - The page keeps the room of the problem alone while the script loads, as the demo starts unexplained (it kept that of the whole demo). - The docs page says where the plot is now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: three views, an orange mechanism, a new fallback figure - The floating layers come in two views: unfolded ("unfolded"), the layers apart, the one pointed at sliding out as the stack's sheets do, its input showing under its marks; and projected ("projected", what "unfolded" was), the layers on the card at rest, unfolding once, the one pointed at casting its marks onto the card. - In both, the layers not pointed at fade as the stack's sheets do, and keep their paper: projected, only the layers above the one pointed at thin theirs (and fade further), so that it shows through them. - The mechanism is a more vibrant orange, and its name under the plot too; "Input" and "Mechanism" are capitalized. - The fallback figure shows the stack as it is now: the plot of the fit upright beside it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a steadier card, a centred house, a more prominent question - The house's table fits its box (a little tighter, the box's sides a little narrower) and sits in its middle; what is wider than its box shrinks about its middle, not to one side. - The card says what an explanation was explained with, on a line of its own ("Explained with GraphSHAP-IQ, exact"): the models' data now have the explainer and how apart (pack.py, data.js). Every explanation's words are the same five lines, each kept to one line, so that none breaks or moves as the next one shows; where a line would not fit the column (on a narrow screen), all shrink alike, and what an explanation holds takes two lines. - "Why f(x)?" stands out more, in the ink, f(x) in the prediction's red, and the Explain tab is larger. - The line that builds the explanation runs behind what it builds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: point at the input, an orange mechanism card, peeking blanks - Of the floating layers, the input's card can be pointed at too (hover, tap, or its name under the plot): the Why card shows the input alone, "no explanation yet", R² 0, nothing is projected onto it, and the layers fade. - The mechanism pointed at turns the Why card orange: its edge, its face (the mechanism's paper), its name, bar and R², and the light out of the chip onto it. - Projected, a blank sheet pointed at peeks out below its strip, as in the other views. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: unfolded, the input slides out too; the mechanism's gap - Unfolded, the input's card pointed at slides out as the layers do, and a layer slides out with its explanation only, without the input under its marks. - An estimated mechanism pointed at (Describing Images) names its estimation gap on the card: "R² 0.91, estimation gap 0.09" (on a phone "gap 0.09"), the gap hatched at the end of its bar, and its terms "estimated". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the stack goes; unfolded is the default, projected the other The explanations float as layers above the input's card, the mechanism below it, in both views that remain: unfolded (the default, as the docs show it), the layer pointed at slides out; projected (data-view = "projected"), it casts its marks onto the card. The stack's sheets, its layout and its drawing go; the layers are drawn ahead while the page is idle instead. The docs page speaks of layers, and its fallback figure shows the unfolded view (quantized by octree, which keeps the mechanism's orange). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: three rules on the plot, a tick at each The upright plot of the fit draws three rules, its lowest R², its middle and 1, each with its tick (on a narrow screen without the leading zero: .5, .75); it drew five, two of them without a tick. The fallback figure shows it so. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: projected, the explanation's light onto the input is green The light from the layer pointed at down onto the input's card is a green box, as the mechanism's rising to it is orange: a green wash, fading less towards the card, and its edges drawn solid; and the card it falls on is edged in green while it wears the explanation's marks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a shorter slide, and the handle's line on to the layer - Unfolded, a layer pointed at slides out less (0.22 of its width, was 0.32): it slid along the line of the layers' edges, and seemed to continue the layer below it. - The layer the slider's handle points at has its line on from its left corner to the handle, solid, as its row's goes on from its right corner to its point in the plot; the layers leave room for it, left of them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a still input, a steady chip, the orders between, the mechanism's handle - The input's card is no longer pointed at: hovering or tapping it does nothing, and it does not slide out. - The chip's R² reads in two decimals, or >.99 short of 1, so that it is as wide whatever it is: the chip, whose words shrink to fit it, keeps its size from one explanation to the next (on a phone it jumped). - Projected, the layers above the one pointed at all but vanish (their paper and edge thinner, their marks fainter). - A blank layer pointed at shows its order's explanation on the Why card, and, projected, casts it onto the input, in green, as a layer does: the data now have the explanations of the orders between the sheets and the highest with an interaction (pack.py, data.js; of the molecule's, the strongest 120 interactions). Describing Images keeps none of its order 5, which shows the input alone. - The slider has a handle of the mechanism's own, at its height, apart from the arrow, on a thinner orange arrow up to the input: pointed at, it brings out the mechanism, fills, and draws its line to it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the slider down to the mechanism, lines on one height, arrowheads - The slider's handle goes on past the last explanation to the mechanism, onto its own handle (End, the arrow keys, or dragging): there, in the mechanism's orange, it brings the mechanism out. - A layer's row's dashed line lay half a pixel below the plot's it goes on to (a border's top, not its middle, at the corner's height): their middles meet now, and the slider's line's too. - Projected, every edge of the light ends at the input in a small arrowhead: green from the layer pointed at, orange from the mechanism. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the slider's arrow down to the input, green below the layer cast The slider's arrow goes on past the explanations down to the input's height, which it points at from above, as the mechanism's orange arrow does from below (each tip a few pixels short of it). Projected, from the layer pointed at down to the input, the arrow and its tip turn green, as the light the layer casts onto the input. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: the estimated mechanism's blur as an SVG filter An estimated mechanism (Describing Images) shows blurred: its layer, its light on the input's card, and the Why card's face of it. The blur was a CSS blur(), which Safari does not draw on SVG's shapes; it is an SVG filter now (a Gaussian blur, a little stronger), which every browser draws, defined once per demo and taken by demo.css through --orders-blur. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019qiuyEoqTxUYBXqUZ7PZqM * Orders demo: a slider with dots, to try (data-rail="dots") With data-rail="dots", the slider is drawn as the mechanism's: a thinner arrow, a hollow circle at every layer (smaller at a blank one), and the handle the circle of the order pointed at, filled (orange at the mechanism's); at rest, no circle is filled, and no handle shows above them (but for the keyboard's focus). Without it, the sl…
1 parent a97d7bd commit 2afdfd7

24 files changed

Lines changed: 7775 additions & 103 deletions

‎docs/source/_ext/shapiq_demos.py‎

Lines changed: 68 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,33 @@
1717
:fallback: images/hero_siglip2.png
1818
:alt: What the fallback image shows.
1919
20-
It writes the demo's container, ``<div class="<name>-demo" data-root="...">``, whose ``data-root``
21-
is the URL of the demo's assets relative to the page, and adds ``demo.css`` and ``demo.js`` to the
22-
page. Without JavaScript, the container shows the fallback image, a file of the built ``_static``
23-
folder.
20+
A demo that builds up step by step shows the step its ``:step:`` names, as the container's
21+
``data-step`` (the orders demo's ``problem``, ``mechanism``, ``shapley``, ``interactions`` and
22+
``full``; without it, all of it), and points at rest at what its ``:select:`` names, as
23+
``data-select`` (the orders demo's ``none``, ``mechanism``, ``full`` or an order, ``1``, ``2``,
24+
...; without it, what the step adds). A demo with examples shows those its ``:examples:`` names, as
25+
``data-examples``, in that order (the orders demo's ``molecule``, ``house``, ``tabpfn``,
26+
``houses`` and ``fixlip``, apart by commas or spaces; without it, all of them; with one, no tabs).
27+
The demos of one page show the same example: choosing one in any of them chooses it in all that
28+
have it.
29+
30+
It writes the demo's container, ``<div class="<name>-demo" data-root="..." data-version="...">``,
31+
whose ``data-root`` is the URL of the demo's assets relative to the page and ``data-version`` a
32+
checksum of its ``data.js`` (for the script to load the data by, past browsers' caches, where the
33+
page has not loaded it), and adds ``demo.css``, ``data.js`` (if the demo has one) and ``demo.js`` to
34+
the page, the data deferred just before the script, so that both load at once. Without JavaScript,
35+
the container shows the fallback image, a file of the built ``_static`` folder. Outside HTML, a demo
36+
is left out.
37+
38+
The assets are copied before the pages are written, so that Sphinx adds its checksums to the links
39+
of ``demo.css`` and ``demo.js``, and they are dependencies of the pages that embed the demo, so that a
40+
change to them writes these pages again.
2441
"""
2542

2643
from __future__ import annotations
2744

2845
import shutil
46+
import zlib
2947
from html import escape
3048
from pathlib import Path
3149
from typing import TYPE_CHECKING, Any, ClassVar
@@ -41,6 +59,7 @@
4159
from sphinx.writers.html5 import HTML5Translator
4260

4361
_ASSETS = ("demo.js", "demo.css") # the files that every demo's assets folder has
62+
_DATA = "data.js" # the demo's data, which its script loads, if it has any
4463

4564

4665
class DemoNode(nodes.General, nodes.Element):
@@ -55,6 +74,9 @@ class DemoDirective(SphinxDirective):
5574
"anchor": directives.unchanged_required, # the container's id, to link to it
5675
"fallback": directives.unchanged_required, # an image of _static, shown without scripts
5776
"alt": directives.unchanged_required, # the fallback image's text
77+
"step": directives.unchanged_required, # of a demo built up step by step, the one to show
78+
"select": directives.unchanged_required, # what the demo points at, at rest
79+
"examples": directives.unchanged_required, # of a demo with examples, those it shows
5880
}
5981

6082
def run(self) -> list[nodes.Node]:
@@ -64,8 +86,16 @@ def run(self) -> list[nodes.Node]:
6486
if missing := [file for file in _ASSETS if not (assets / file).is_file()]:
6587
msg = f"the demo {name!r} has no {', '.join(missing)} in demos/{name}/assets"
6688
raise self.error(msg)
67-
node = DemoNode(demo=name, fallback=self.options.get("fallback"))
89+
for file in (*_ASSETS, _DATA):
90+
if (assets / file).is_file():
91+
self.env.note_dependency(str(assets / file))
92+
data = assets / _DATA
93+
version = f"{zlib.crc32(data.read_bytes()):08x}" if data.is_file() else ""
94+
node = DemoNode(demo=name, fallback=self.options.get("fallback"), version=version)
6895
node["alt"] = self.options.get("alt", "")
96+
node["step"] = self.options.get("step", "")
97+
node["select"] = self.options.get("select", "")
98+
node["examples"] = self.options.get("examples", "")
6999
if "anchor" in self.options:
70100
node["ids"].append(self.options["anchor"])
71101
return [node]
@@ -74,9 +104,11 @@ def run(self) -> list[nodes.Node]:
74104
def _visit_demo(self: HTML5Translator, node: DemoNode) -> None:
75105
page = self.builder.get_target_uri(self.builder.current_docname)
76106
root = relative_uri(page, f"_static/demos/{node['demo']}/")
77-
self.body.append(
78-
self.starttag(node, "div", CLASS=f"{node['demo']}-demo", **{"data-root": root})
79-
)
107+
attributes = {"data-root": root, "data-version": node.get("version", "")}
108+
for option in ("step", "select", "examples"):
109+
if node.get(option):
110+
attributes[f"data-{option}"] = node[option]
111+
self.body.append(self.starttag(node, "div", CLASS=f"{node['demo']}-demo", **attributes))
80112
if node["fallback"]:
81113
src = relative_uri(page, f"_static/{node['fallback']}")
82114
self.body.append(
@@ -89,6 +121,11 @@ def _depart_demo(self: HTML5Translator, node: DemoNode) -> None: # noqa: ARG001
89121
self.body.append("</div>\n")
90122

91123

124+
def _skip_demo(self: nodes.NodeVisitor, node: DemoNode) -> None: # noqa: ARG001
125+
"""Leave a demo out of a build that is not HTML (text, LaTeX, ...)."""
126+
raise nodes.SkipNode
127+
128+
92129
def _add_assets(
93130
app: Sphinx,
94131
pagename: str, # noqa: ARG001
@@ -102,12 +139,16 @@ def _add_assets(
102139
for name in sorted({node["demo"] for node in doctree.findall(DemoNode)}):
103140
# the stylesheet after html_css_files, whose tokens.css it uses
104141
app.add_css_file(f"demos/{name}/demo.css", priority=900)
142+
# the data, if any, just before the script and loaded alongside it (not by it, once it has
143+
# run): the script uses the data on the page, and loads it itself where it is missing
144+
if (Path(app.srcdir) / "demos" / name / "assets" / _DATA).is_file():
145+
app.add_js_file(f"demos/{name}/{_DATA}", loading_method="defer", priority=499)
105146
app.add_js_file(f"demos/{name}/demo.js", loading_method="defer")
106147

107148

108-
def _copy_assets(app: Sphinx, exception: Exception | None) -> None:
109-
"""Copy every demo's assets to ``_static/demos/<name>/`` of the built docs."""
110-
if exception is not None or app.builder.format != "html":
149+
def _copy_assets(app: Sphinx, env: object) -> None: # noqa: ARG001
150+
"""Copy every demo's assets to ``_static/demos/<name>/``, before the pages are written."""
151+
if app.builder.format != "html":
111152
return
112153
for assets in sorted((Path(app.srcdir) / "demos").glob("*/assets")):
113154
target = Path(app.outdir) / "_static" / "demos" / assets.parent.name
@@ -116,8 +157,21 @@ def _copy_assets(app: Sphinx, exception: Exception | None) -> None:
116157

117158
def setup(app: Sphinx) -> ExtensionMetadata:
118159
"""Register the directive, its node and the assets."""
119-
app.add_node(DemoNode, html=(_visit_demo, _depart_demo))
160+
skip = (_skip_demo, None)
161+
app.add_node(
162+
DemoNode,
163+
html=(_visit_demo, _depart_demo),
164+
latex=skip,
165+
text=skip,
166+
man=skip,
167+
texinfo=skip,
168+
)
120169
app.add_directive("shapiq-demo", DemoDirective)
121170
app.connect("html-page-context", _add_assets)
122-
app.connect("build-finished", _copy_assets)
123-
return {"version": "1.0", "parallel_read_safe": True, "parallel_write_safe": True}
171+
app.connect("env-updated", _copy_assets)
172+
return {
173+
"version": "1.0",
174+
"env_version": 2, # the nodes carry a version: environments of earlier builds are read again
175+
"parallel_read_safe": True,
176+
"parallel_write_safe": True,
177+
}
-11 KB
Loading
84.1 KB
Loading
163 KB
Loading

‎docs/source/conf.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ def __repr__(self) -> str:
247247
"sg_execution_times.rst",
248248
# the demos' notes for maintainers, assets and scripts, which are not pages
249249
"demos/README.md",
250+
"demos/*/README.md",
250251
"demos/*/assets",
251252
"demos/*/compute",
252253
]

‎docs/source/demos/README.md‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ run with the docs: its data is computed by hand and committed.
1111
demos/
1212
├── index.rst the Demos page: a card per demo, and the toctree
1313
└── <name>/
14-
├── index.rst the demo's page: the demo (`.. shapiq-demo:: <name>`) and its write-up
14+
├── index.rst the demo's page: the demo (`.. shapiq-demo:: <name>`) and its write-up (the
15+
│ orders demo has none: its card opens the guide that builds it up)
16+
├── README.md optional: notes for maintainers on how the demo is built and embedded
1517
├── assets/ what the page loads: demo.js, demo.css and the demo's data
1618
└── compute/ the scripts that computed the data, with a README on how to run them
1719
```
@@ -26,11 +28,22 @@ one (the landing page embeds the FIxLIP demo):
2628
:alt: What the fallback image shows.
2729
```
2830

29-
It writes `<div class="<name>-demo" data-root="...">`, where `data-root` is the URL of the demo's
30-
assets relative to the page, and adds `assets/demo.css` and `assets/demo.js` to the page; the
31-
build copies `assets/` to `_static/demos/<name>/`. The script finds its container by the class,
32-
loads its data from `data-root`, and fills the container. Without JavaScript, the container shows
33-
the fallback image, a file of `_static/` (all options are optional).
31+
It writes `<div class="<name>-demo" data-root="..." data-version="...">`, where `data-root` is the
32+
URL of the demo's assets relative to the page and `data-version` a checksum of `assets/data.js`,
33+
and adds `assets/demo.css`, `assets/data.js` (if there is one) and `assets/demo.js` to the page,
34+
the data deferred just before the script, so that both load at once; the build copies `assets/` to
35+
`_static/demos/<name>/` before it writes the pages, so that their links to the assets carry
36+
checksums too, and writes the pages with a demo again when its assets change. The script finds its
37+
container by the class, uses the data the page loaded (or, where it is missing, loads it from
38+
`data-root`, with `?v=` and the version, past browsers' caches), and fills the container. Without
39+
JavaScript, the container shows the fallback image, a file of `_static/` (all options are
40+
optional). Builders other than HTML leave demos out.
41+
42+
Three more options are passed on to the demo's script, as `data-step`, `data-select` and
43+
`data-examples`, for the demos that read them (the orders demo does, the FIxLIP demo does not):
44+
`:step:` shows one step of a figure built up step by step, `:select:` what it points at at rest,
45+
and `:examples:` only the examples it names, in that order (`:examples: tabpfn`, or
46+
`house, houses`). `orders/README.md` lists their values.
3447

3548
The folders `assets/` and `compute/` and this README are not pages of the docs (`exclude_patterns`
3649
in `conf.py`).
@@ -39,4 +52,7 @@ in `conf.py`).
3952

4053
1. Make the folder `demos/<name>/` with `index.rst`, `assets/demo.js`, `assets/demo.css` and the
4154
data, and `compute/` with the scripts that computed the data and a README on how to run them.
42-
2. Add a card for it to `demos/index.rst` and its page to the toctree there.
55+
2. Add a card for it to `demos/index.rst` and its page to the toctree there. The cards' images
56+
(`_static/images/hero_<name>_demo.png`) are screenshots of the demos, 1952 x 1252: the demo at
57+
about 2x, in the middle of a white frame with a 2 px `#e2e6f3` edge and 26 px corners, so that
58+
the cards match (see `orders/README.md`).

0 commit comments

Comments
 (0)