-
-
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
use inference data in end of sampling report #3883
Conversation
pymc3/backends/report.py
Outdated
@@ -107,7 +107,7 @@ def _run_convergence_checks(self, trace, model): | |||
self._add_warnings([warn]) | |||
return | |||
|
|||
from pymc3 import rhat, ess | |||
from pymc3 import rhat, ess, _to_arviz |
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 have used this to_arviz
approach for readability, but I can change it to from arviz import from_pymc3
if you prefer it
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.
Could _to_arviz
be a place where to put storing of sampling metadata? (See arviz-devs/arviz#1146)
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 definitely think it has to be added to from_pymc3
so also to _to_arviz
, is that the question?
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 didn't know _to_arviz
existed, so to me it sounds like code duplication?
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 aliased from_pymc3
to _to_arviz
, I was worried calling a function called from_pymc3
inside pymc code would be confusing. I guess it depends on the general degree of familiarity with ArviZ
Codecov Report
@@ Coverage Diff @@
## master #3883 +/- ##
=======================================
Coverage 90.71% 90.71%
=======================================
Files 135 135
Lines 21314 21316 +2
=======================================
+ Hits 19335 19337 +2
Misses 1979 1979
|
@OriolAbril do you think we could transition to returning |
Now that ArviZ is a dependency, it is feasible, however it would be quite a breaking change. It should probably be discussed in an issue or lab meeting. Another alternative would be to add an option to |
I like the idea of having an option to return an inference data object! Would make the modeling workflow easier and more elegant. |
Returning an |
But we already have a converter to swallow |
Ah, right. I had forgotten. And it's already ported to |
I think that the steps to transition to an
The way in which the future warnings is dealt with usually is by setting the default argument value to something that indicates that the user did not explicitly provide anything as it's value (could be |
ced029d
to
9b697f6
Compare
Addressed the comments about using inference data to avoid memory usage peaks due to pointwise log likelihood. I would leave returning an inference data object as a result of |
@OriolAbril Looks great -- thanks! Can you add a note to the release-notes under maintenance? |
Thanks @OriolAbril ! |
Current code calls
az.ess
andaz.rhat
using trace objects instead of inference data objects. ArviZ therefore converts the trace to inferencedata object twice. This is generally not an issue and it is barely noticeable unless the number of observations is large, in which case the conversion (and consequent retrieving of pointwise log likelihood data) can be quite memory expensive. Below there is memory usage in an example (courtesy of @nitishp25) where the effect is quite noticeable:This PR explicits the conversion to inferencedata so it only happens once, and if possible, skips retrieving the pointwise log likelihood data (which is not needed for ess nor rhat calculation).