Lapylace

lapylace is the formula-first Bayesian regression layer used in these translations. It provides a Python interface analogous to the everyday rstanarm::stan_glm() and simple brms workflow while using CmdStanPy for compilation, sampling, posterior summaries, and ArviZ conversion.

import lapylace as lp

The common model shape is:

# fit = lp.stan_glm(
#     "y ~ x1 + x2",
#     data=df,
#     family=lp.gaussian(),
#     prior=lp.normal(0, 2.5),
#     prior_intercept=lp.normal(0, 5),
#     chains=4,
#     iter_sampling=1000,
# )

Supported likelihoods in the initial package are Gaussian identity-link regression, Bernoulli logit regression, Poisson log regression, and grouped-binomial logit regression. Each model produces posterior draws, posterior predictions, pointwise log likelihoods, and an ArviZ InferenceData object for PSIS-LOO.

# fit.summary()
# fit.posterior_epred(new_data)
# fit.posterior_predict(new_data)
# fit.loo()

The package lives in a separate git repository at /Users/alal/Desktop/code/lapylace.