arviz-devs / preliz

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

Add pymc support to predictive explorer #450

Closed rohanbabbar04 closed 1 month ago

rohanbabbar04 commented 1 month ago

Description

aloctavodia commented 1 month ago

sample_prior_predictive emits a message. saying "Samplig", plus a list of the sampled variables. We should disable that message. It is generated with the logging module. We should suppress it locally with a context manager, or disable it before sampling and enable it again after sampling. We need to do this to avoid messing up calls to sample_prior_predictive outside of predictive_explorer

aloctavodia commented 1 month ago

It is not needed for this PR, but something to think about.

We may want to try to guess the value of "engine", for instance for a pymc model we could inspect the source and detect the regex pattern for "with pm.Model() as" where the particle "pm." is something that can vary. For Bambi it should also be simple to detect it.

We may want to keep the "engine" argument and default to "auto" or something similar, just in case our automatic detection fails

rohanbabbar04 commented 1 month ago

sample_prior_predictive emits a message. saying "Samplig", plus a list of the sampled variables. We should disable that message. It is generated with the logging module. We should suppress it locally with a context manager, or disable it before sampling and enable it again after sampling. We need to do this to avoid messing up calls to sample_prior_predictive outside of predictive_explorer

Created a contextmanager to handle the logs generated during this step.

rohanbabbar04 commented 1 month ago

It is not needed for this PR, but something to think about.

We may want to try to guess the value of "engine", for instance for a pymc model we could inspect the source and detect the regex pattern for "with pm.Model() as" where the particle "pm." is something that can vary. For Bambi it should also be simple to detect it.

We may want to keep the "engine" argument and default to "auto" or something similar, just in case our automatic detection fails

Sounds good.... Let me create a new issue for this

rohanbabbar04 commented 1 month ago

I am currently keeping the sampling pymc code separated from the preliz code, like it was discussed in the jupyter notebook. Better to not disrupt the current implementation of the already existing preliz code. If required we can combine the codes later...

aloctavodia commented 1 month ago

agreed, we can refactor and combine later. Something really easy to combine is the plotting part, right?

rohanbabbar04 commented 1 month ago

agreed, we can refactor and combine later. Something really easy to combine is the plotting part, right?

Yes...