-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
return_inferencedata option for pm.sample #3911
return_inferencedata option for pm.sample #3911
Conversation
+ convert to InferenceData and save metadata to it already in sample() + pass idata instead of trace to convergence check, to avoid duplicate work + directly use arviz diagnostics instead of pymc3 aliases
This is the first stage - converting to I'm going to wait for the tests before adding the |
Codecov Report
@@ Coverage Diff @@
## master #3911 +/- ##
==========================================
- Coverage 86.40% 83.49% -2.91%
==========================================
Files 86 103 +17
Lines 13728 14192 +464
==========================================
- Hits 11861 11849 -12
- Misses 1867 2343 +476
|
+ set to None + defaults to False
Tests are green. |
Replaced "<varname>: <type>" with "<varname> : <type>" per numpy guidelines. Fix spelling typo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, pending tests.
Probably needs some additional tests that exercise returning InferenceData
.
I've added a test for the new kwarg. As So this PR is ready for review - I'll update the release notes when I address your upcoming feedback. |
You'll notice a I'm in contact with Oriol to get |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Michael, this looks good to me 👌
I'll merge tomorrow morning, in case @rpgoldman or @ColCarroll request some last-minute changes.
@michaelosthege, as discussed, @OriolAbril's warmup PR was merged on ArviZ repo, and the next ArviZ release will be 0.8.0, so I think we can reactivate work on this PR and address the comments we made above 👌 |
Yes, we can wait for the ArviZ release. |
We should probably either convert one of the example notebooks to using this throughout, or create a new one. The |
+ more direct use of ArviZ + some wording things
@AlexAndorra and @OriolAbril thank you for the feedback on the notebook! they were really straightforward to apply. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot @michaelosthege ! There was a small typo left, and I left a question about how to handle warmups 😉 Going to review the NB now.
View / edit / reply to this conversation on ReviewNB AlexAndorra commented on 2020-05-26T10:37:17Z Can you set |
View / edit / reply to this conversation on ReviewNB AlexAndorra commented on 2020-05-26T10:37:18Z Typo: "With Also, maybe put this line below the next cell, otherwise it makes it seems like you're showing the place where tuning samples are kept in ID. |
View / edit / reply to this conversation on ReviewNB AlexAndorra commented on 2020-05-26T10:37:18Z You have to set the kwarg |
View / edit / reply to this conversation on ReviewNB AlexAndorra commented on 2020-05-26T10:37:19Z To use the Data container through the end you can set the new values like this, in the model context (see this tutorial for more): with model: pm.set_data({'x_obs': [-1, 0, 1.0], "y_obs": [0, 0, 0]}) post_pred = pm.sample_posterior_predictive(idata.posterior) Let's also use the default number of samples, as earlier.
|
@michaelosthege , finished reviewing the NB -- just a few tweaks to add / typos to fix and we'll be good to go 👌 |
The pipelines fails because of arviz-devs/arviz#1210 I could make a workaround for the test case, but I also think having |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The NB is a marvel now, thanks a lot for your patience and perseverance on this @michaelosthege !
Waiting for ArviZ 0.8.3 to be released, and I'll merge if tests pass then -- I really, really hope no other edge case will pop up this time 😅 🤞
Problems seem to be fixed on ArviZ master, but before releasing 0.8.3, we need to make sure this really works. To do that, the best would be that Travis tests against ArviZ master, not only against the latest release -- @canyon289 do you know if it's possible and how easy it would be? |
Given that @michaelosthege has successfully run the tests locally, I'll merge tomorrow to make release 0.8.3 and hope for the best. |
@OriolAbril was emboldened by your successful local tests and released ArviZ 0.8.3 @michaelosthege, so you can push your last changes and I'll merge if tests pass 🤞 |
🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've done it, well done guys 👏 Quite a team 💪
Most PyMC3 modeling workflows (should) at some point use ArviZ to save and load traces as
InferenceData
objects.With a
sample(…, return_inferencedata=True/False)
option, the conversion may happen as early as possible, encouraging the user to use ArviZ from the start.wait for next ArviZ release to happen
update PR such that
NotImplementedError
there are no breaking changes to the user-facing API - but a
FutureWarning
is added, allowing us to default toreturn-inferencedata=True
inv4.0.0
if it turns out to be a good ideain use inference data in end of sampling report #3883, Oriol made some optimizations to avoid duplicate work of conversion. This PR does the same by doing the conversion already in
sample()
and passing theidata
for convergence checks.are the changes—especially new features—covered by tests and docstrings? -- test was added, other tests remain untouched, so they assert that the user-facing API did not break
consider adding/updating relevant example notebooks - I'll do that on a future PR
right before it's ready to merge, mention the PR in the RELEASE-NOTES.md