-
-
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
Model API cleanup #6309
Model API cleanup #6309
Conversation
8a81537
to
43e3f05
Compare
de31798
to
0121fd9
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6309 +/- ##
==========================================
+ Coverage 91.87% 94.18% +2.31%
==========================================
Files 111 111
Lines 23917 23908 -9
==========================================
+ Hits 21973 22518 +545
+ Misses 1944 1390 -554
|
0121fd9
to
a94805a
Compare
a94805a
to
0fc9a9d
Compare
9246301
to
29e8e05
Compare
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.
Trusting that you'll fix that one test 👍
This also disables prior_predictive sampling of transformed variables
This property was initially added just to handle deterministics created by automatic imputation, in order to ensure the combined tensor of missing and observed components showed up in prior and posterior predictive sampling. At the same time, it allowed hiding the deterministic during mcmc sampling, saving memory use for large datasets. This last benefit is lost for the sake of simplicity. If a user is concerned, they can manually split the observed and missing components of a dataset when defining their model.
29e8e05
to
60f15e1
Compare
@@ -343,7 +362,7 @@ def sample_prior_predictive( | |||
var_names : Iterable[str] | |||
A list of names of variables for which to compute the prior predictive | |||
samples. Defaults to both observed and unobserved RVs. Transformed values | |||
are not included unless explicitly defined in var_names. | |||
are not allowed. |
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.
Any reason why transformed (unconstrained) values are not allowed here? I need to get prior samples in the transformed space, what should I do? Thanks!
(MCMC sampling by removing observations from the likelihood is not a good option. I guess I could also use sample_prior_predictive
to get prior parameter samples and then transform back to the unconstrained space but it seems not easy to do it with Transforms
in an efficient vectorized way, i.e., it seems I have to do a for-loop.)
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.
A helper to go from unconstrained back to constrained draws is needed elsewhere (specially since we don't save them in InferenceData after sampling), so we can add that and will also cover your use case.
I think there is an open issue for that.
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.
This issue: #6721
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 for the quick reply! Transforming efficiently between unconstrained and constrained draws would be super useful for our use case. What would be needed for its implementation? In the meantime, what could be a good workaround? (I need to transform a lot of prior samples from constrained to unconstrained. Or alternatively, unconstrained prior samples are even more useful to me than constrained samples. So it would be better if I could get them directly.) Can I modify back sample_prior_predictive
to include the transformed variables like sd_log__
?
For the InferenceData, pm.sample(..., idata_kwargs={"include_transformed": True})
seems to include the transformed
samples.
Hi, please see my comment above. Any reason why transformed (unconstrained) values are not allowed in |
No we shouldn't change I'll open a PR soon to add the functionality. |
Trying to standardize mapping names a bit more to facilitate model transformations such as in pymc-devs/pymc-extras#91
Closes #6305
Closes #5076
Major / Breaking Changes
prior_predictive
is no longer allowedBugfixes / New features
Docs / Maintenance
Model
variables