Skip to content

Bayesian workflow example#797

Merged
fonnesbeck merged 6 commits into
pymc-devs:mainfrom
fonnesbeck:bayes_workflow2
Jun 20, 2025
Merged

Bayesian workflow example#797
fonnesbeck merged 6 commits into
pymc-devs:mainfrom
fonnesbeck:bayes_workflow2

Conversation

@fonnesbeck

@fonnesbeck fonnesbeck commented Jun 19, 2025

Copy link
Copy Markdown
Member

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/

@review-notebook-app

Copy link
Copy Markdown

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@fonnesbeck

Copy link
Copy Markdown
Member Author

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

@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

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.

@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

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

twiecki commented Jun 19, 2025

Copy link
Copy Markdown
Member

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

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

@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

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..."


@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

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")


@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

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)


@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

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


@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

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

plt.show() not neccesary?


@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

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...


@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

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

"sampels"


Copy link
Copy Markdown
Member Author

I don't understand the question.


View entire conversation on ReviewNB

Copy link
Copy Markdown
Member

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


View entire conversation on ReviewNB

Copy link
Copy Markdown
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
Copy Markdown
Member Author

OK, I've fixed this. Thanks.


View entire conversation on ReviewNB

@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

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

This can be removed


@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

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

Add ;


@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

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

Also add ;


@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

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

Add ;


@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

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

Add ;


@review-notebook-app

review-notebook-app Bot commented Jun 19, 2025

Copy link
Copy Markdown

View / edit / reply to this conversation on ReviewNB

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

Add ;


@fonnesbeck

Copy link
Copy Markdown
Member Author

Everyone cool with these changes?

Comment thread examples/case_studies/bayesian_workflow.myst.md
@fonnesbeck fonnesbeck merged commit 57a24c0 into pymc-devs:main Jun 20, 2025
2 checks passed
@fonnesbeck fonnesbeck deleted the bayes_workflow2 branch June 20, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants