From 62f73dca389f3b7c02dd334faeaf0f5bff25ccfc Mon Sep 17 00:00:00 2001 From: Jammy2211 Date: Mon, 14 Sep 2026 21:23:25 +0100 Subject: [PATCH] docs: simplify the model figure prose to two fixed paragraphs Replace the map/legend prose block beside every `af.ModelPlotter` figure with two fixed paragraphs, deleting the file-specific reading commentary that followed it, and strip the same figure-rendering vocabulary (pills, plates, badges, greyed pills, footer counts) from the shorter notes at later figure sites. The human's verdict: the commentary is information overload and the figure should be self-explanatory. Teaching content that happened to sit inside those blocks is preserved, reworded to stand on its own without referring to the figure's vocabulary. The EP factor-graph blocks are exempt: box / pill / edge is standard probabilistic-graphical-model notation, and the state overlay carries per-factor update counts, ages and statuses that `graph.info` does not provide. Image `:alt:` text is exempt too, since describing what a figure looks like is its purpose. Issue: https://github.com/PyAutoLabs/autofit_workspace/issues/156 Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01LPCvGNHahZqynPyEfMijsb --- docs/cookbooks/model.md | 22 ++++++++++----------- docs/cookbooks/multi_level_model.md | 15 +++++++++------ docs/cookbooks/multiple_datasets.md | 21 +++++++++++--------- docs/features/graphical.md | 30 ++++++++++++----------------- 4 files changed, 43 insertions(+), 45 deletions(-) diff --git a/docs/cookbooks/model.md b/docs/cookbooks/model.md index 34e4cfac6..b50b908cd 100644 --- a/docs/cookbooks/model.md +++ b/docs/cookbooks/model.md @@ -111,7 +111,12 @@ normalization LogUniformPrior [2], lower_limit = 1e-06, upper_li sigma UniformPrior [3], lower_limit = 0.0, upper_limit = 25.0 ``` -We can also draw the model, via `af.ModelPlotter`: +The same model can also be visualized as a figure, making its structure easier to understand at a glance. + +The figure shows how the model is organized: which parameters belong to each component, and whether they are free, +fixed, shared, linked by an expression, solved during the fit, or not configured. `model.info` provides the +corresponding numerical details, including the prior assigned to each free parameter and the value of each fixed +parameter. ```python af.ModelPlotter(model).figure() @@ -122,13 +127,8 @@ af.ModelPlotter(model).figure() :width: 600 ``` -The figure is the **map** of a model and the `info` above is its **legend**: the map shows the structure, meaning -which components own which parameters and which of those parameters are fixed, shared, related to one another or -constrained, whereas the `info` lists the priors and values themselves. For a model this simple the two say much the -same thing, but the map is what stays readable as models grow. - Setting `model_figure: true` in a workspace's `config/output.yaml` writes this figure as a `model.png` beside -`model.info` for every search, so every fit keeps its own map. +`model.info` for every search. ## Priors (Model) @@ -321,8 +321,7 @@ af.ModelPlotter(model).figure() :width: 600 ``` -The fixed `centre` is drawn greyed out and the footer counts it as a fixed leaf slot rather than a sampled scalar, so -the map says at a glance that this model is fitted with two free parameters and not three. +The `centre` is now fixed rather than sampled, so this model is fitted with two free parameters and not three. The overwriting of priors shown above can be achieved via the following alternative API: @@ -676,9 +675,8 @@ af.ModelPlotter(model).figure() :width: 600 ``` -The map puts the two fixed values (`gaussian.normalization` and `exponential.centre`) and the assertion -`exponential.rate > 5.0` into a single read. The assertion in particular does not appear in the `info` above at all, -which is the clearest case of the map carrying something the legend cannot. +This model fixes two values (`gaussian.normalization` and `exponential.centre`) and adds the assertion +`exponential.rate > 5.0`. The assertion in particular does not appear in the `info` above at all. Below is an alternative API that can be used to create the same model as above. diff --git a/docs/cookbooks/multi_level_model.md b/docs/cookbooks/multi_level_model.md index c232fc4d7..03c8bf3b9 100644 --- a/docs/cookbooks/multi_level_model.md +++ b/docs/cookbooks/multi_level_model.md @@ -107,7 +107,12 @@ gaussian_list sigma UniformPrior [4], lower_limit = 0.0, upper_limit = 25.0 ``` -The hierarchy the `info` indents is what the model figure draws as containment: +The same model can also be visualized as a figure, making its structure easier to understand at a glance. + +The figure shows how the model is organized: which parameters belong to each component, and whether they are free, +fixed, shared, linked by an expression, solved during the fit, or not configured. `model.info` provides the +corresponding numerical details, including the prior assigned to each free parameter and the value of each fixed +parameter. ```python af.ModelPlotter(model).figure() @@ -118,11 +123,9 @@ af.ModelPlotter(model).figure() :width: 600 ``` -The figure is the **map** of the model and the `info` above is its **legend**: the map shows which component owns -which parameters, so `higher_level_centre` sits in the outer `MultiLevelGaussians` card while the two `Gaussian`'s -sit inside the `gaussian_list` frame nested within it. That is exactly the reason to use a multi-level model, drawn -rather than indented, and the repeated `Gaussian`'s are collapsed into a single frame labelled with how many -components it stands for. +The `higher_level_centre` belongs to the outer `MultiLevelGaussians` object whereas the two `Gaussian`'s are +contained within its `gaussian_list`. That hierarchy is the reason to use a multi-level model, and the `info` above +can only express it as indentation. ## Instances diff --git a/docs/cookbooks/multiple_datasets.md b/docs/cookbooks/multiple_datasets.md index bbbad7a20..96728945d 100644 --- a/docs/cookbooks/multiple_datasets.md +++ b/docs/cookbooks/multiple_datasets.md @@ -172,8 +172,12 @@ To inspect the model, we print `factor_graph.global_prior_model.info`. print(factor_graph.global_prior_model.info) ``` -The figure is the **map** of this global model and the `info` is its **legend**: the map shows the structure, meaning -which dataset gets which component and which parameters are shared between them, while the `info` lists the priors. +The same model can also be visualized as a figure, making its structure easier to understand at a glance. + +The figure shows how the model is organized: which parameters belong to each component, and whether they are free, +fixed, shared, linked by an expression, solved during the fit, or not configured. `model.info` provides the +corresponding numerical details, including the prior assigned to each free parameter and the value of each fixed +parameter. ```python af.ModelPlotter(factor_graph.global_prior_model).figure() @@ -184,9 +188,8 @@ af.ModelPlotter(factor_graph.global_prior_model).figure() :width: 600 ``` -Because every dataset is fitted by the same `Gaussian`, the three components collapse into one frame and each of -`centre`, `normalization` and `sigma` carries a shared badge, which is the picture of a three-parameter fit to three -datasets. +Because every dataset is fitted by the same `Gaussian`, this global model has just three free parameters, `centre`, +`normalization` and `sigma`, which are shared across all three datasets. To fit multiple datasets, we pass the `FactorGraphModel` to a non-linear search. @@ -422,8 +425,8 @@ af.ModelPlotter(factor_graph.global_prior_model).figure() :width: 600 ``` -Only `centre` now carries the shared badge; `normalization` and `sigma` are marked as independent, meaning one prior -per dataset, and the footer counts the seven unique sampled scalars this makes. +Only `centre` is now shared between the datasets, whereas `normalization` and `sigma` have one prior per dataset, +giving seven free parameters in total. Fit this model to the data using dynesty. @@ -572,8 +575,8 @@ af.ModelPlotter(factor_graph.global_prior_model).figure() :width: 600 ``` -Each dataset's `sigma` pill states the expression that defines it, and `centre` and `normalization` are badged as -shared, so the map says directly that adding a fourth dataset would add a fourth card and no new parameters. +Each dataset's `sigma` is defined by an expression rather than sampled, and `centre` and `normalization` are shared +between the datasets, so adding a fourth dataset would add no new free parameters. We can fit the model as per usual. diff --git a/docs/features/graphical.md b/docs/features/graphical.md index 561bb1c23..08ea69c9d 100644 --- a/docs/features/graphical.md +++ b/docs/features/graphical.md @@ -153,11 +153,9 @@ af.ModelPlotter(factor_graph.global_prior_model).figure() :width: 600 ``` -The dashed frame is a **plate**: one `Gaussian` drawn once, standing for all three datasets, labelled `3 datasets`. The -`centre` shared by every dataset is hoisted out into the card above, joined to the plate by a blue line, and its chip -inside the plate carries a blue `shared` badge. The `normalization` and `sigma` chips are marked `independent`, because -each dataset gets a prior of its own, and the green `data` chip is the observed dataset. The footer counts the fit the -prose below describes: 1 shared across datasets, 2 per dataset × 3 datasets, 7 unique sampled scalars. +Every dataset is fitted by the same `Gaussian`, whose `centre` is one prior shared across all three datasets, +whereas `normalization` and `sigma` each have a prior per dataset. That is 1 shared parameter plus 2 per dataset +across 3 datasets, 7 free parameters in total. The factor graph above is made up of two components: @@ -188,30 +186,27 @@ dataset one-by-one. ## Shared Or Hierarchical -Sharing a parameter and drawing it hierarchically sound alike in words but are different models, and the figure is -the quickest way to tell them apart. +Sharing a parameter and drawing it hierarchically sound alike in words but are different models. -A **shared** parameter is one prior object used by every dataset, so the datasets fit literally the same number. Share -all three of `centre`, `normalization` and `sigma` and every chip carries the blue `shared` badge, the hoisted card -holds all three, and 3 datasets cost 3 sampled scalars: +A **shared** parameter is one prior object used by every dataset, so the datasets fit literally the same number. +Share all three of `centre`, `normalization` and `sigma` and 3 datasets cost just 3 free parameters: ```{image} https://raw.githubusercontent.com/PyAutoLabs/PyAutoFit/main/docs/images/model_figures/graphical_shared.png :alt: The model figure of a fully shared graphical model, with centre, normalization and sigma hoisted into one shared card and each chip badged shared. :width: 600 ``` -A **hierarchical** parameter is different for every dataset, but each one is *drawn* from a parent distribution whose -own parameters are fitted. Drawn is not shared. Give each dataset's `centre` an `af.HierarchicalFactor` parent and the -figure hoists that parent into a violet card of its own, holding the `mean` and `sigma` of the distribution, with a -violet arrow running into the `centre` chip, which reads `centre · drawn`: +A **hierarchical** parameter is different for every dataset, but each one is *drawn* from a parent distribution +whose own parameters are fitted. Drawn is not shared. Give each dataset's `centre` an `af.HierarchicalFactor` parent +and that parent contributes a `mean` and a `sigma` of its own to the model: ```{image} https://raw.githubusercontent.com/PyAutoLabs/PyAutoFit/main/docs/images/model_figures/graphical_hierarchical.png :alt: The model figure of a hierarchical graphical model, with a violet HierarchicalFactor card holding mean and sigma and a violet arrow into the drawn centre chip inside the plate. :width: 600 ``` -The footers say what this costs: the shared figure counts 3 unique sampled scalars, the hierarchical one 2 -hyper-parameters plus 3 per dataset × 3 datasets, so 11. This hierarchical composition is the model built in +The two cost different amounts: the shared model has 3 free parameters, the hierarchical one 2 hyper-parameters +plus 3 per dataset × 3 datasets, so 11. This hierarchical composition is the model built in [HowToFit chapter 3, tutorial 4](https://github.com/PyAutoLabs/HowToFit/blob/main/notebooks/chapter_3_graphical_models/tutorial_4_hierachical_models.ipynb). ## Expectation Propagation @@ -244,8 +239,7 @@ the structure alone, written once at the start of the run: ``` Square boxes are factors, rounded pills are variables, and a line is an incidence: this variable is one of that -factor's arguments. The dashed frame is a plate, exactly as in the model figures above -- three `AnalysisFactor`s with -the same signature are drawn once, and a variable each of them has its own copy of is drawn once inside the plate +factor's arguments. The dashed frame is a plate -- three `AnalysisFactor`s with the same signature are drawn once, and a variable each of them has its own copy of is drawn once inside the plate badged `x3`. The `HierarchicalFactor0` box collapses its three members the same way, reading `3 members`, with its own `mean` and `sigma` as hyper-variables above it.