Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Replacing PyMC3 plots w/ Arviz plots & sigma Param change [Part 3] #25

Merged

Conversation

CloudChaoszero
Copy link
Contributor

Description

The following is a large PR breakdown of PR #16.

Replace PyMC3 dependent plots with arviz plots in case studies & examples.

Replace parameter sd with sigma (e.g. some examples have pm.Normal(...sd=...)

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@MarcoGorelli
Copy link
Contributor

Hi @CloudChaoszero - it looks like the watermarks haven't changed, could you please run the notebooks top-to-bottom? It may be that some other parts need updating (I've often found that when updating old notebooks)

…h sigma

🎨 Full Notebook runs and minor Warnings cleanup
@CloudChaoszero
Copy link
Contributor Author

@MarcoGorelli Pardon about that. haha I went ahead and did the full runs, and squashed the commits.

@CloudChaoszero
Copy link
Contributor Author

Small note

There were a couple of errors I encountered like:

examples/diagnostics_and_criticism/Diagnosing_biased_Inference_with_Divergences.ipynb:

  • divergent_point had a dimension/indice error in section
ii = 5

tau_log_d = divergent_point["tau_log__"]
theta0_d = divergent_point["theta"][:, ii]
Ndiv_recorded = len(tau_log_d)

So I removed the [:, ii], since it's a singular dimension array, and not 2-dim.

examples/diagnostics_and_criticism/Bayes_factor.ipynb:

  • parallel=True caused an error. It is recorded as a defect, based on this issue
        trace = pm.sample_smc(1000, random_seed=42, parallel=True)

@MarcoGorelli
Copy link
Contributor

MarcoGorelli commented Feb 7, 2021

Thanks @CloudChaoszero for updating!

TBH I'm really not keen on adding

warnings.filterwarnings("ignore", category=FutureWarning)
warnings.filterwarnings("ignore", category=UserWarning)

. If there's a specific warning that needs disabling in one cell, then OK, but disabling everywhere doesn't strike me as a great practice. CC @AlexAndorra any thoughts on disabling warnings in notebooks?

@AlexAndorra
Copy link
Collaborator

If there's a specific warning that needs disabling in one cell, then OK, but disabling everywhere doesn't strike me as a great practice. CC @AlexAndorra any thoughts on disabling warnings in notebooks?

I agree with @MarcoGorelli : we already know many people don't pay enough attention to warnings, so if we also disable them in notebooks, that makes our job more difficult. On the contrary, displaying them in notebooks is a great way to make people more aware of important warnings -- for instance, users should really know that we're gonna switch to InferenceData by default at one point, and make breaking changes in the next major version, etc.

@review-notebook-app
Copy link

review-notebook-app bot commented Feb 7, 2021

View / edit / reply to this conversation on ReviewNB

OriolAbril commented on 2021-02-07T21:02:50Z
----------------------------------------------------------------

The magenta lines in the right subplot are gone somehow


CloudChaoszero commented on 2021-02-08T06:17:38Z
----------------------------------------------------------------

Yeah, I'm not to sure why, either.

* I was able to update the other recommendations though, outside of this comment.

@@ -2,14 +2,8 @@
"cells": [
Copy link
Member

@OriolAbril OriolAbril Feb 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest using:

ppc_w = pm.sample_posterior_predictive_w(
    traces,
    models=[model_0, model_1, model_2],
    weights=comp.weight.sort_index(ascending=True),
    progressbar=True,
)

Reply via ReviewNB

@@ -2,14 +2,8 @@
"cells": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here:

ppc_2 = pm.sample_posterior_predictive(trace_2, model=model_2, progressbar=False)

Reply via ReviewNB

@@ -2,14 +2,8 @@
"cells": [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why there is a mean after the call to hdi, I would suggest doing:

hpd_w = az.hdi(ppc_w["kcal"].flatten())

instead. If I'm not wrong, between this and the changes to sample_... there won't be a need to ignore warnings anymore everything will have been solved and will follow best practices


Reply via ReviewNB

@@ -2,26 +2,48 @@
"cells": [
Copy link
Member

@OriolAbril OriolAbril Feb 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no need to ignore warnings in this notebook, ArviZ does not warn about the change in default anymore.


Reply via ReviewNB

@review-notebook-app
Copy link

review-notebook-app bot commented Feb 7, 2021

View / edit / reply to this conversation on ReviewNB

OriolAbril commented on 2021-02-07T21:02:53Z
----------------------------------------------------------------

no need to ignore warnings here either


@@ -16,15 +16,36 @@
"cell_type": "code",
Copy link
Member

@OriolAbril OriolAbril Feb 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This plot is actually az.plot_energy the cell can be reduced to a single line (could be done in a follow up PR)


Reply via ReviewNB

@CloudChaoszero
Copy link
Contributor Author

If there's a specific warning that needs disabling in one cell, then OK, but disabling everywhere doesn't strike me as a great practice. CC @AlexAndorra any thoughts on disabling warnings in notebooks?

I agree with @MarcoGorelli : we already know many people don't pay enough attention to warnings, so if we also disable them in notebooks, that makes our job more difficult. On the contrary, displaying them in notebooks is a great way to make people more aware of important warnings -- for instance, users should really know that we're gonna switch to InferenceData by default at one point, and make breaking changes in the next major version, etc.

Yeah, I just did it to not show my local path when the Warnings come up. lol

I can remove them going forward, if you all are okay with that.

Copy link
Contributor Author

Yeah, I'm not to sure why, either.

* I was able to update the other recommendations though, outside of this comment.


View entire conversation on ReviewNB

Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should open an issue about the wrong plot parallel in the divergences notebook so we don't forget to fix eventually everything else looks good

@twiecki twiecki merged commit d50e6a5 into pymc-devs:main Mar 8, 2021
@CloudChaoszero CloudChaoszero deleted the replace-pymc3-arviz-plots_part3 branch April 5, 2021 01:52
twiecki pushed a commit that referenced this pull request Jan 17, 2023
* update tests, update aesara import

* infer shape
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.

5 participants