Skip to content

Posterior Plot Generators

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.

from src.diagnostics.posterior_predictive_plot import generate_ppc_plot
generate_ppc_plot(
model: Any,
config: dict[str, Any],
results_dir: str,
) -> str | None
FilenameStage folderDescription
posterior_predictive_check.png30_model_assessment/ArviZ posterior predictive density overlay (num_pp_samples=100) against observed data.
  • If posterior_predictive is missing, the function attempts to generate it via pm.sample_posterior_predictive(..., extend_inferencedata=True).
  • Returns saved path on success, otherwise None.
from src.diagnostics.posterior_forest import generate_posterior_forest_plot
generate_posterior_forest_plot(
model: Any,
config: dict[str, Any],
results_dir: str,
) -> str | None
FilenameStage folderDescription
posterior_forest.png20_model_fit/Forest plot for beta_channel with 94% HDI.
posterior_forest_all_params.png20_model_fit/Forest plot for available key parameters among beta_channel, alpha, lam, with 94% HDI.
  • Uses HDI_PROB = 0.94.
  • Returns the main posterior_forest.png path when available.
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 | None
FilenameStage folderDescription
prior_posterior_comparison.png20_model_fit/ArviZ distribution comparison (plot_dist_comparison) of prior and posterior.
  • If prior is 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.
from src.diagnostics.posterior_forest import generate_posterior_forest_plot
from src.diagnostics.posterior_predictive_plot import generate_ppc_plot
from 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)
  • Stages: 20_model_fit/ and 30_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, and pareto_k_summary.json in 50_diagnostics/.