Posterior Plot Generators
Overview
Section titled “Overview”This page documents three visual diagnostic generators used after model fitting:
- posterior predictive fit checking,
- posterior forest plots,
- prior-versus-posterior comparison.
They provide fast visual evidence for fit quality and parameter identifiability.
1) Posterior Predictive Check
Section titled “1) Posterior Predictive Check”Function Signature
Section titled “Function Signature”from src.diagnostics.posterior_predictive_plot import generate_ppc_plot
generate_ppc_plot( model: Any, config: dict[str, Any], results_dir: str,) -> str | NoneArtefact
Section titled “Artefact”| Filename | Stage folder | Description |
|---|---|---|
posterior_predictive_check.png | 30_model_assessment/ | ArviZ posterior predictive density overlay (num_pp_samples=100) against observed data. |
Behaviour
Section titled “Behaviour”- If
posterior_predictiveis missing, the function attempts to generate it viapm.sample_posterior_predictive(..., extend_inferencedata=True). - Returns saved path on success, otherwise
None.
2) Posterior Forest Plots
Section titled “2) Posterior Forest Plots”Function Signature
Section titled “Function Signature”from src.diagnostics.posterior_forest import generate_posterior_forest_plot
generate_posterior_forest_plot( model: Any, config: dict[str, Any], results_dir: str,) -> str | NoneArtefacts
Section titled “Artefacts”| Filename | Stage folder | Description |
|---|---|---|
posterior_forest.png | 20_model_fit/ | Forest plot for beta_channel with 94% HDI. |
posterior_forest_all_params.png | 20_model_fit/ | Forest plot for available key parameters among beta_channel, alpha, lam, with 94% HDI. |
Behaviour
Section titled “Behaviour”- Uses
HDI_PROB = 0.94. - Returns the main
posterior_forest.pngpath when available.
3) Prior-Posterior Comparison
Section titled “3) Prior-Posterior Comparison”Function Signature
Section titled “Function Signature”from src.diagnostics.prior_posterior_comparison import generate_prior_posterior_comparison
generate_prior_posterior_comparison( model: Any, config: dict[str, Any], results_dir: str,) -> str | NoneArtefact
Section titled “Artefact”| Filename | Stage folder | Description |
|---|---|---|
prior_posterior_comparison.png | 20_model_fit/ | ArviZ distribution comparison (plot_dist_comparison) of prior and posterior. |
Behaviour
Section titled “Behaviour”- If
prioris missing on idata, the function attempts to generate prior samples (pm.sample_prior_predictive(samples=500)) and extend idata. - Returns saved path on success, otherwise
None.
Usage Example
Section titled “Usage Example”from src.diagnostics.posterior_forest import generate_posterior_forest_plotfrom src.diagnostics.posterior_predictive_plot import generate_ppc_plotfrom src.diagnostics.prior_posterior_comparison import generate_prior_posterior_comparison
generate_posterior_forest_plot(driver.model, driver.config, driver.results_dir)generate_prior_posterior_comparison(driver.model, driver.config, driver.results_dir)generate_ppc_plot(driver.model, driver.config, driver.results_dir)Relationship to Workflow Stages and Gates
Section titled “Relationship to Workflow Stages and Gates”- Stages:
20_model_fit/and30_model_assessment/. - These plots support gate review and model criticism but are not standalone machine gate fields.
- They should be interpreted alongside
convergence_report.json,calibration_report.json, andpareto_k_summary.jsonin50_diagnostics/.