Skip to content
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

fix default prior variable names #3591

Merged
merged 3 commits into from Aug 16, 2019
Merged

Conversation

OriolAbril
Copy link
Member

Fix #3588. I have also noted that sample_prior_predictive samples both the prior and the prior_predictive. Considering how default var names are defined now. It would be quite easy to divide the function in 2, a sample_prior and a sample_prior_predictive but it would be quite a breaking change. Are you interested in dividing the function at all? Would you rather do in now or in some future PR after having added FutureWarnings here?

I think the best idea will probably be to make this PR only about fixing #3588 so it can be merged before the discussion about prior and prior predictive. I can send another PR afterwards with whatever is decided.

@OriolAbril
Copy link
Member Author

I think this is ready to merge. It fixes the issue in the cases I tested locally and I added a test to make sure pm.Data objects are not returned by sample_prior_predictive. If there is anything missing please let me know.

Copy link
Member

@aloctavodia aloctavodia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of splitting this function into two, why not adding an argument something like include_prior=True, or include="both"("prior", "predictive")

vars = set(model.named_vars.keys())
vars_ = model.named_vars
prior_pred_vars = model.observed_RVs
prior_vars = get_default_varnames(model.unobserved_RVs, include_transformed=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will exclude potentials (model.potentials)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know these existed. Should they be included in prior_vars or prior_pred_vars?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potentials are a way to add arbitrary terms to the computation of the logp. You can use them to add constraints to the model. I will add them to prior_vars

@@ -505,12 +505,14 @@ def test_ignores_observed(self):
observed = np.random.normal(10, 1, size=200)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove unused variable?

@aloctavodia aloctavodia merged commit 3a2a765 into pymc-devs:master Aug 16, 2019
@OriolAbril OriolAbril deleted the sample_prior branch April 15, 2020 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sample_prior_predictive returns pm.Data variables too
4 participants