-
-
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
Add examples explaining advanced applications of sample_posterior_predictive
#7014
Conversation
b41e474
to
1f41d6a
Compare
var_names
in sample_posterior_predictive
var_names
in sample_posterior_predictive
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7014 +/- ##
=======================================
Coverage 92.24% 92.24%
=======================================
Files 100 100
Lines 16887 16887
=======================================
Hits 15577 15577
Misses 1310 1310
|
f0dccc7
to
3d0f869
Compare
3d0f869
to
72e15b1
Compare
var_names
in sample_posterior_predictive
var_names
in sample_posterior_predictive
Last suggestion, getting into the weeds of personal preferences -- I think the API docs would look nicer if you added a title (in bold or italics or w/e) to each of the two examples. I also think the code in the new section would be easier to follow if you split the model definition plus each function call into a separate code block and wrote your commentary as text instead of code comments. |
I agree, even better would be a markdown header, but I don't know if that's supported :D |
I think you can use restructuredtext subsubsection headings, like: Example 1: Exploring the effect of See here. It's pretty hideous for viewing in an IDE, though. |
That worked @jessegrabowski |
pymc/sampling/forward.py
Outdated
|
||
.. code:: python | ||
|
||
pm.sample_posterior_predictive(idata, var_names=["obs"], **kwargs) |
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.
Given this is called default behaviour, I would make it pm.sample_posterior_predictive(idata)
nothing else.
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.
I think this helps understanding how the behavior changes when you start playing with it the kwarg
Thanks @ricardoV94 , these clarifications are very much welcome!
Seems like default ppc is done and you only need predictions use-case? |
71b1061
to
712d82f
Compare
var_names
in sample_posterior_predictive
sample_posterior_predictive
I have addressed several review comments:
I also expanded with two new example sections:
It's ready for review again. It is also likely I messed up the myst formatting so any help appreciated. |
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.
Love it @ricardoV94 ! Just suggested a few changes, then good to merge
712d82f
to
6a30632
Compare
@AlexAndorra thanks for the review and suggestions. I've addressed them |
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.
All good, thanks @ricardoV94 🥳
Just waiting for an answer to solve link formatting -- and took the opportunity to add a nit 😜
pymc/sampling/forward.py
Outdated
Note that "sampling" a :func:`~pymc.Deterministic` does not force random variables | ||
that depend on this quantity to be sampled too. In the following example ``z`` will not | ||
be resampled even though it depends on ``det_xy``: |
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.
Now that we have to wait for Oriol's answer on the extrernal link before merging, let me add a nit 🙈
I don't think it'll be super clear to all users that z
depends on det_xy
, because it looks like it only depends on x
and y
.
If you did this: z = pm.Normal("z", det_xy)
, that'd probably be clearer. Not a big deal, just my 2 cents
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.
That's what I actually wanted to do! Wonder if the bug comes bug up... xD
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.
Ah ok! Then that makes more sense
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.
It shows the bug again! I added a separate commit that includes a danger section
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.
Opened an issue: #7183
6a30632
to
08fca4e
Compare
Things seem to be working. @AlexAndorra wanna do one last 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.
All good now @ricardoV94 🍾
This is still a draft. I want to add two more examples first about the default ppc and predictions use-cases
Related to #7069
TODO
Explain volatility when MutableData changesI think this is itself a mine-field and I would rather change the behavior firstLink to function docs preview: https://pymcio--7014.org.readthedocs.build/projects/docs/en/7014/api/generated/pymc.sampling.forward.sample_posterior_predictive.html
📚 Documentation preview 📚: https://pymc--7014.org.readthedocs.build/en/7014/