arviz-devs / preliz

A tool-box for prior elicitation.
https://preliz.readthedocs.io
Apache License 2.0
73 stars 9 forks source link

predictive_explorer with bambi model KeyError #460

Closed andins closed 1 month ago

andins commented 1 month ago

Describe the bug I just installed the package and tried the docs example for predictive_explorer with a bambi model. I get a KeyError: 'a_mu'. image

To Reproduce The notebook to reproduce the error is just the code in the docs but I attach it anyway.

import preliz as pz
import numpy as np
import bambi as bmb
import pandas as pd

data = pd.DataFrame(
    {
        "y": np.random.normal(size=100),
        "x": np.random.normal(size=100),
    }
)
def a_bambi_model(a_mu, a_sigma):
    prior = {"Intercept": bmb.Prior("Normal", mu=a_mu, sigma=a_sigma)}
    a_model = bmb.Model("y ~ x", data, priors=prior)
    return a_model

pz.predictive_explorer(a_bambi_model)

Additional context I'm using llvmlite-0.42.0 numba-0.59.1 preliz-0.7.0 ipympl-0.9.4 ipython-genutils-0.2.0 nbclient-0.5.13

aloctavodia commented 1 month ago

The documentation is reflecting changes on the main branch not yet released. It should work if you install from main.

aloctavodia commented 1 month ago

A new version has been released. The example should work. Notice that the Bambi and PyMC features for predictive_explorer are very new and still under development. If you find bugs we would love to hear about them. Thanks

andins commented 1 month ago

thank you very much @aloctavodia ! Now it works. It still breaks with a multilevel model but I guess you already know and it's expected since it's under development.

aloctavodia commented 1 month ago

Hi @andins do you mean it fails with a multilevel Bambi's model?