mixle.inference.decision module¶
Bayes-optimal decisions under a fitted mixle posterior.
Given a Posterior (the Monte-Carlo law over an unknown – a
parameter, a latent state, or a future outcome), a loss function loss(action, draw) -> float, and a
finite set of candidate actions, bayes_action() returns the action that minimises the posterior
expected loss and a tail-risk profile (CVaR + loss quantiles) of the chosen action.
This is the decision half of the platform’s differentiator: a point predictor returns a number; a mixle model returns the action that is optimal under the user’s own loss and honest about its tail risk.
It depends only on the public Posterior.samples(n, rng) contract
(mixle.inference.posterior), so it carries no serving / HTTP opinion – a lack of capability is
reported via mixle.capability.CapabilityError.
- bayes_action(posterior, loss, actions, *, n=2000, seed=0, cvar_alpha=0.1, quantiles=(0.05, 0.5, 0.95))[source]
Pick the Bayes action:
argmin_a E_{draw ~ posterior}[ loss(a, draw) ].- Parameters:
posterior (Any) – any object exposing
samples(n, rng)– e.g.mixle.inference.posterior(model, data, over=...)(parameter, latent, or predictive).loss (Callable[[Any, Any], float]) –
loss(action, draw) -> float(or a numpy-vectorizedloss(action, draws) -> array).actions (Sequence[Any]) – the finite candidate-action set to minimise over.
n (int) – number of posterior draws for the Monte-Carlo expectation.
seed (int) – RNG seed for the posterior draw (reproducible).
cvar_alpha (float) – tail mass for the CVaR / VaR of the chosen action (0.1 -> worst 10%).
quantiles (Sequence[float]) – loss quantiles to report per action.
- Returns:
{action, action_index, expected_loss, risk_profile, alternatives}– the chosen action, its expected loss, its tail-risk profile, and the expected loss of every candidate.- Raises:
ValueError – if
actionsis empty.CapabilityError – if
posteriordoes not expose thesamples(n, rng)contract.
- Return type: