Repository navigation
Plate-notation model figures for graphical models - #1617
Merged
Merged
Conversation
…AutoFit#1616) Snapshot taken at laptop shutdown; not tested/shipped. Resume from the active.md row of model-figures-graphical in PyAutoMind. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0178yLU9v19GtACcRPFggjGa
Phase 4 of the model-figures epic: a `FactorGraphModel`'s global model now draws as plate notation, so a graphical model is a picture rather than a paragraph. graph_spec: a graphical pass keyed off `GlobalPriorModel.factor` adds hyper nodes for each `_HierarchicalFactor`, a `DrawEdge` from the hyper node to every drawn variable, observed rows for each analysis' data, a `FactorInfo` record of the `model.info` paths a hyper node replaces, and the graphical counts (hyper-parameters, shared across datasets, per dataset, datasets). presentation: the "shared across datasets" card is hoisted above the dataset plates, drawn and observed parameters get their own pills, and the footer splits into the graphical counts. render: a violet arrow draws each draw edge from the hoisted hyper card into the pill it lands on. docs: `docs/features/graphical.md` replaces the "we haven't yet built visualization" sentence with the figure of the page's own factor graph, and a "Shared Or Hierarchical" section contrasting a shared prior (blue badge, one hoisted card, 3 sampled scalars) with a hierarchical draw (violet card and arrow, 11 sampled scalars), tied to HowToFit chapter 3 tutorial 4. Three new PNGs under `docs/images/model_figures/` are written by `make_figures.py`. tests: `test_autofit/graph_spec/test_graphical.py` and `test_autofit/model_figure/test_graphical_presentation.py`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AmyBwcVQBrWE4jSTqdATY6
This was referenced Sep 12, 2026
Merged
Collaborator
Author
|
Workspace PR: PyAutoLabs/autofit_workspace#153 |
Collaborator
Author
|
Workspace PR: PyAutoLabs/HowToFit#51 |
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.
Summary
Phase 4 of the model-figures epic:
af.ModelPlotternow draws plate notation for graphical models.Passing a
FactorGraphModel'sglobal_prior_modelto the plotter produces a figure where repeatedper-dataset structure collapses into a dashed dataset plate badged with the dataset count, shared
priors are hoisted into a card above the plate and linked back to it, hierarchically drawn
parameters carry a
drawnpill fed by a violet arrow from theirHierarchicalFactorcard, observeddata enters as a green
observedpill, and the footer splits the parameter count intohyper-parameters, per-dataset parameters and unique sampled scalars.
This fills the three "visualization not implemented" holes:
docs/features/graphical.md,autofit_workspace/scripts/features/graphical_models.pyand HowToFit chapter 3 (workspace PRs linkedbelow), and ships the shared-vs-hierarchical teaching pair.
API Changes
None — no public symbol added, removed, renamed or re-signatured (
autofit/__init__.pyis unchanged).The change is behavioural:
af.ModelPlotter(...).figure()previously drew a factor graph's globalmodel as ordinary repeated cards; it now detects the graphical structure and renders plate notation
(plates, hoisted shared cards, draw arrows, observed rows, hyper/per-dataset footer). Figures of
non-graphical models are unchanged.
See full details below.
Test Plan
pytest test_autofit/— 2759 passed, 2 skipped, 0 failedtest_autofit/graph_spec/test_graphical.py,test_autofit/model_figure/test_graphical_presentation.pyblack --check+pyflakesclean on touched filesmainbaseline (30)docs/images/model_figures/make_figures.pyand reviewedFull API Changes (for automation & release notes)
Removed
Added (internal — not exported from
autofit)autofit.graph_spec.FactorInfo— frozen dataclass describing a factor (name, dataset index, observed rows)autofit.graph_spec.DrawEdge— frozen dataclass for a hierarchical draw (parent factor → drawn prior), used instead of a sharing linkGraphSpec.graphical_counts(raw_root)— hyper / per-dataset / unique-scalar counts for the footerautofit.model_figureinternals: dataset-plate detection, shared-prior hoisting, draw-route rendering,observed/drawn/sharedpill states, split footerChanged Signature (internal)
autofit.graph_spec._path_index(spec, model, hyper_paths=None)— new optional argumentautofit.model_figure.presentation._badge_colours(badge, state="free")— new optional argumentChanged Behaviour (public)
af.ModelPlotter(factor_graph.global_prior_model).figure()— renders plate notation for graphical/hierarchical models instead of repeated per-dataset cardsMigration
Opened under Heart RED (release validation FAILED, stage integrate — unrelated autolens scripts) with explicit human authorisation on 2026-09-12; merge stays human via /prm.
Generated by the PyAutoLabs agent workflow.
🤖 Generated with Claude Code
https://claude.ai/code/session_01AmyBwcVQBrWE4jSTqdATY6