pymc-examples
pymc-examples copied to clipboard
Added Generalized Extreme Value distribution example
This PR adds a notebook example to go alongside the addition of the Generalized Extreme Value distribution to pymc v4 opened in PR https://github.com/pymc-devs/pymc/pull/5085
Check out this pull request onΒ ![]()
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
Thanks for your PR! I have added the hold for v4 tag to make sure it is merged after the beta release is out. This will ensure the notebook is reproducible from the watermark only (pymc version doesn't include commit info) as well as not having the "You are running the v4 development version of PyMC which currently still lacks key features." in our documentation examples.
Also make sure to follow the style guide: https://github.com/pymc-devs/pymc/wiki/PyMC-Jupyter-Notebook-Style-Guide. This will ensure the notebook is easily discoverable via tags, contains all the necessary info to rerun from the watermark and overall tries to set all the notebooks in the example gallery to a similar style so readers know what to expect.
I also noticed you have not listed yourself as author, which is also something we are currently discussing to make sure we clearly credit everyone who contributes to the example gallery. See https://github.com/pymc-devs/pymc-examples/issues/198 for example if you are interested in this or https://pymc-examples--239.org.readthedocs.build/en/239/splines/spline.html (generated from #239) to see a proposal of how authorship attribution could look like.
Thanks for the great comments @OriolAbril ! I think I've addressed everything; the splines example was super useful too!
Please let me know of anything else.
Edit: the notebook metadata and citations didn't render very well. I'm not sure if this is related to recent changes at https://github.com/pymc-devs/pymc-examples/issues/198 or something I've done, though the markup seems fine.
I tried the ppc plot with priors but got the following error:
`TypeError Traceback (most recent call last)
/opt/anaconda3/lib/python3.8/site-packages/arviz/plots/ppcplot.py in plot_ppc(data, kind, alpha, mean, observed, color, colors, grid, figsize, textsize, data_pairs, var_names, filter_vars, coords, flatten, flatten_pp, num_pp_samples, random_seed, jitter, animated, animation_kwargs, legend, labeller, ax, backend, backend_kwargs, group, show)
208 for groups in (f"{group}_predictive", "observed_data"):
209 if not hasattr(data, groups):
--> 210 raise TypeError(f'data argument must have the group "{groups}" for ppcplot')
211
212 if kind.lower() not in ("kde", "cumulative", "scatter"):
TypeError: data argument must have the group "prior_predictive" for ppcplot`
@Dawar-812 This is probably an Arviz issue, but can you check that you have the group 'prior' in your InferenceData prior_pc object? And that you're using Arviz v. 0.11.4?
@ccaprani Here is the code: `data_pc = pm.sample_prior_predictive(samples=1000, model=model_gev) az.plot_ppc(data_pc, group="prior", figsize=(12, 6)) ax = plt.gca() ax.set_xlim([2, 6]) ax.set_ylim([0, 2]);
` Yes, I am using Arviz v. 0.11.4
@Dawar-812 this PR is using the development version of pymc. To reproduce the results you need to install pymc from github which is still changing in preparation for the soon to be released 4.0.beta release and lacks some key features (as the warning on import shows also here on the notebook). Now, sampling methods by default return InferenceData objects, so you can take their output and use arviz functions straight away, for this to work in pymc 3.11.x you need to manually convert the output to inferencedata before calling plot_ppc
Looks great and everything renders correctly now, thanks so much!
The only reason I am not approving is to prevent someone too eager to merge before v4 is released :smile:
The "Add PyMC3 classes used to tags" hook fails - I guess this should be removed or updated for v4?
The "Add PyMC3 classes used to tags" hook fails - I guess this should be removed or updated for v4?
we are looking into it, we might replace it altogether with an alternative instead of updating, don't pay attention to it for now. We have also added a pre-commit check for the bibtex file to keep it tidy and sorted. Do you mind rebasing? I could also do it at some point next week if you prefer but if the notebook needs more changes you'll need to be careful pulling after my force push.
We have now removed the pymc classes as tags and will use a different approach for them. You should remove the pymc. tags and CI will pass again. You should also remove the table_of_contents files that are no longer being used and have been removed.
Can you remove all pymc.* or pymc3.* tags in the first code cell?
@OriolAbril @drbenvincent I'm surprisingly hopeful we can close this out at some point :-) I can't see there's anything?? Thanks.
Will set the checks running, but from memory I think we don't need examples/table_of_contents_examples.js any more. Taking a look now.
Just a few things:
- Delete the file
examples/table_of_contents_examples.js. It's not needed any more. - Should "Authored by Colin Caprani, October 2021" be updated in terms of the date?
- Have you tried cranking up the
target_accepteven higher?
Otherwise, looks good and can approve ππ»
Sorry, one more thing. Just noticed that there's a fail of the pre-commit checks relating to references.bib. You might need to re-run the pre-commit checks twice, they can be a bit iffy.
Not 100% sure why the test is failing, but if the branch is a bit old, you might need to rebase to incorporate more recent changes in this file.
Thanks for that feedback and review @drbenvincent !
Changes made. We're investigating more on the reasons for divergences, but pushing the target-accept higher does improve it. We don't observe this in our research problems, but for this data set it appears. C'est la vie!
The pre-commit hooks pass locally. I think it might have needed the myst.md file added to the commit?
The remote pre-commit checks are failing. I suspect that the things may have changed since you created the branch to work on this. So you might need to rebase.
I'm a bit trial and error with this, but could try
git remote add upstream https://github.com/pymc-devs/pymc-examples.git
git fetch upstream main
git rebase upstream/main
then re-run the pre-commit process and cross fingers.
Sorry this is taking a while, I know how frustrating these pre-commit checks can be!
Thanks for your patience @drbenvincent ! It had skipped the bibtex-tidy check the last time; but all good now - I think bibtex-tidy is sorting the refs by id; all sorted now!
Thanks for your help closing this out @drbenvincent π