BayesianModelSelection#

class gammapy.modeling.BayesianModelSelection[source]#

Bases: object

Bayesian inference for a set of alternative models.

This class automates the workflow of evaluating several alternative statistical models on the same datasets, extracting posterior and prior information, and computing predictive accuracy metrics such as WAIC and PSIS‑LOO. The results for each model are stored in InferenceResult objects and collected into a BayesianModelSelectionResult.

The run method loops over a dictionary of candidate models, runs the sampler for each one, and computes summaries of parameter estimates and model‑comparison statistics. These summaries include log‑evidence, AIC, WAIC, LOO, effective degrees of freedom, and Pareto‑k diagnostics. Progress, parameter tables, and statistical summaries are emitted using the Python logging system at the INFO level.

Parameters:
samplerSampler

Sampler instance specifying the backend and options.

posterior_downsample_factorint, optional

Factor to downsample posterior samples for efficiency. Default is 4.

n_prior_samplesint, optional

Number of prior samples to display on the results. If None, no prior samples are added. Default is 1000.

Methods Summary

run(datasets, alternative_models)

Run Bayesian inference for a set of alternative models.

Methods Documentation

run(datasets, alternative_models)[source]#

Run Bayesian inference for a set of alternative models.

Parameters:
datasetsDatasets

The datasets on which to perform the model fitting.

alternative_modelsdict

Dictionary of model names and corresponding Models objects.

Returns:
resultBayesianModelSelectionResult

Object containing the results of the model comparisons.

__init__(sampler, posterior_downsample_factor=4, n_prior_samples=1000)[source]#
classmethod __new__(*args, **kwargs)#