Skip to content

Bayesian workflow example #797

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

fonnesbeck
Copy link
Member

@fonnesbeck fonnesbeck commented Jun 19, 2025

A notebook adapted from course material on how to implement Gelman et al.'s Bayesian workflow, using a COVID-19 dataset.

Helpful links


📚 Documentation preview 📚: https://pymc-examples--797.org.readthedocs.build/en/797/

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@fonnesbeck
Copy link
Member Author

Not sure if this belongs in case studies or elsewhere ...

Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

twiecki commented on 2025-06-19T14:52:53Z
----------------------------------------------------------------

A lot of these have not plot?


fonnesbeck commented on 2025-06-19T19:58:54Z
----------------------------------------------------------------

I don't understand the question.

aloctavodia commented on 2025-06-19T20:06:11Z
----------------------------------------------------------------

I think he means that a lot of the plots are not visible...

fonnesbeck commented on 2025-06-19T20:11:30Z
----------------------------------------------------------------

That's odd. Will ask Oriol about this. Would be a shame if we can't use plotly in the docs.

fonnesbeck commented on 2025-06-19T20:48:38Z
----------------------------------------------------------------

OK, I've fixed this. Thanks.

Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

twiecki commented on 2025-06-19T14:55:49Z
----------------------------------------------------------------

Maybe add COVID-19 or infection modeling to the title.


@twiecki
Copy link
Member

twiecki commented Jun 19, 2025

Not sure if this belongs in case studies or elsewhere ...

Either case-study or howto, leaning towards the latter.

Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T18:40:00Z
----------------------------------------------------------------

The first two sentences could be "Bayesian modeling is a robust approach to draw conclusions from data. Successful modeling involves an interplay..."


Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T18:40:01Z
----------------------------------------------------------------

A slightly different way to write this would be

dist = pz.Gamma()

pz.maxent(dist, lower=0.1, upper=20, mass=0.95);

Then, in the next cell

fig = px.histogram(x=dist.rvs(1000), nbins=20, title="Gamma Distribution Samples")

fig.show()

and in the model

alpha = dist.to_pymc("alpha")


Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T18:40:01Z
----------------------------------------------------------------

we can use

alpha = pz.maxent(pz.Gamma(), lower=0.1, upper=20, mass=0.95, plot=False).to_pymc("alpha")

instead of

  gamma_params = pm.find_constrained_prior(

    pm.Gamma, lower=0.1, upper=20, init_guess={"alpha": 6, "beta": 1}, mass=0.95

  )

  alpha = pm.Gamma("alpha", **gamma_params)


Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T18:40:02Z
----------------------------------------------------------------

plt.tight_layout() not neccesary given that we are using "arviz-doc" style


Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T18:40:03Z
----------------------------------------------------------------

plt.show() not neccesary?


Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T18:40:03Z
----------------------------------------------------------------

Just for your information "New ArviZ", has functionality for prior/likelihood sensitivity checks, see https://arviz-devs.github.io/EABM/Chapters/Sensitivity_checks.html

No needed to be done now, but maybe in a next round of revision we could use "new arviz" its new prior checks, or new plot like rank plots...


Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T18:40:04Z
----------------------------------------------------------------

"sampels"


Copy link
Member Author

I don't understand the question.


View entire conversation on ReviewNB

Copy link
Member

I think he means that a lot of the plots are not visible...


View entire conversation on ReviewNB

Copy link
Member Author

That's odd. Will ask Oriol about this. Would be a shame if we can't use plotly in the docs.


View entire conversation on ReviewNB

Copy link
Member Author

OK, I've fixed this. Thanks.


View entire conversation on ReviewNB

Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T21:03:15Z
----------------------------------------------------------------

This can be removed


Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T21:03:16Z
----------------------------------------------------------------

Add ;


Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T21:03:16Z
----------------------------------------------------------------

Also add ;


Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T21:03:17Z
----------------------------------------------------------------

Add ;


Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T21:03:18Z
----------------------------------------------------------------

Add ;


Copy link

review-notebook-app bot commented Jun 19, 2025

View / edit / reply to this conversation on ReviewNB

aloctavodia commented on 2025-06-19T21:03:18Z
----------------------------------------------------------------

Add ;


@fonnesbeck
Copy link
Member Author

Everyone cool with these changes?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants