mixle.inference.explain module¶
explain – exact per-part attribution of a model’s score for one observation.
Because mixle models are generative and structured, a prediction’s score decomposes exactly — no surrogate models, no sampling approximations:
a Composite / Record factorizes over fields:
log p(x) = sum_i log p_i(x_i)a learned Bayesian network factorizes over nodes:
log p(x) = sum_i log P(x_i | parents)a Mixture adds the latent view: per-component responsibilities, then the winner’s field breakdown.
explain(model, x) returns those parts with their exact log-likelihood contributions, sorted so the
most suspicious part (lowest contribution) is first — “WHICH field makes this record unlikely” is read
straight off the model rather than estimated:
ex = explain(model, record)
ex.parts # [(name, log-contribution), ...] ascending (most anomalous first)
ex.total # == model.log_density(record), exactly
ex.responsibilities # mixtures: posterior over components