models.stacking_weights()
Stacking weights from pointwise held-out log predictive densities
Usage
models.stacking_weights(lpd)(Yao et al., 2018): the weights on the simplex that maximize the log score of the mixture of the models’ predictive distributions.
Works for any model: pass PSIS-LOO pointwise values (Elpd.pointwise) for a Bayesian fit, or cross-validated log densities for any other. A model that adds nothing gets weight exactly 0.
Parameters
lpd: list of list of float- One list per model, each with one log density per observation.
Returns
list of float- One weight per model, summing to 1.
Examples
>>> from prospicio.models import stacking_weights
>>> w = stacking_weights([[-0.1, -0.1, -3.0, -3.0], [-3.0, -3.0, -0.1, -0.1]])
>>> [round(x, 9) for x in w][0.5, 0.5]