Reference / binference.inference.Auto

binference.inference.Auto

class binference.inference.Auto(model, *, target_ess=400.0, gibbs_max_missing=0.98, nnz_limit=20000000.0, max_gibbs_draws=25000, rng=None, progress=False, **engine_kwargs)[source]

Picks Gibbs, Laplace or NUTS from rules set by a benchmark of the engines.

It tries Gibbs where it mixes well, then importance-corrected Laplace where its check passes, then NUTS, keeping only engines that take every option in engine_kwargs. How auto chooses states the rules and the benchmark. The result records the choice and the reason in info["auto_method"] and info["auto_reason"].

Parameters:
modelPopulationModel
target_essfloat

Smallest bulk ESS that Gibbs’s run length aims for and that Laplace’s importance ESS must reach.

gibbs_max_missingfloat

Largest missing-information fraction for which Gibbs is chosen (0.98: an integrated autocorrelation time of 99 iterations).

nnz_limitfloat

Above this many stored likelihood entries Laplace is kept even when its check fails, rather than running NUTS.

max_gibbs_drawsint

Most draws per chain a Gibbs run may be extended to before it gives way to the next candidate.

rng, progress

As for every engine.

**engine_kwargs

Options for the chosen engine.

__init__(model, *, target_ess=400.0, gibbs_max_missing=0.98, nnz_limit=20000000.0, max_gibbs_draws=25000, rng=None, progress=False, **engine_kwargs)[source]

Methods

__init__(model, *[, target_ess, ...])

candidates([n_samples])

(engine, reason, Gibbs draws per chain) in the order they are tried.

run([n_samples])

Run the first candidate that applies (see the class docstring).

unsupported(model)

Why the engine cannot run on model, or None when it can.

Attributes

approximate

joint

whether the engine infers a selection from injections or a tallied response jointly (DECISIONS #30, #80, #81)

markov

whether its draws are Markov chains, described by R-hat and ESS

name

candidates(n_samples=None)[source]

(engine, reason, Gibbs draws per chain) in the order they are tried.

Parameters:
n_samplesint, optional

Draws per chain of the runs; None uses the engines’ own lengths.

joint = True

whether the engine infers a selection from injections or a tallied response jointly (DECISIONS #30, #80, #81)

run(n_samples=None)[source]

Run the first candidate that applies (see the class docstring).

Parameters:
n_samplesint, optional

Draws per chain; None lets auto set the run length. Laplace returns as many in total as NUTS’s default four chains would (4000 by default).