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

Possibility to pick number of samples for calls to posterior predictive? #739

Open
AlexanderFengler opened this issue Oct 18, 2023 · 6 comments · May be fixed by #871
Open

Possibility to pick number of samples for calls to posterior predictive? #739

AlexanderFengler opened this issue Oct 18, 2023 · 6 comments · May be fixed by #871
Labels
feature request good first issue If you want to contribute but are not sure where to get started, this issue is for you!

Comments

@AlexanderFengler
Copy link

It is often useful / sufficient for posterior predictives (examples for purposes of plotting) to be based on less than all samples from a given call to .fit().

It seems like currently one cannot pick the number of samples at the level of the posterior predictive.

Would it be possible to add this as a small feature (or allow passing through of such parameter to the pm.sample_posterior_predictive() call?

@tomicapretto
Copy link
Collaborator

It's definitely possible but not 100% trivial. Bambi does not use pm.sample_posterior_predictive() under the hood (maybe we should!). It uses pm.draw(dist(**kwargs)) and the number of draws we obtain depends on the shape of the array(s) in kwargs. To decrease the number of draws from the posterior predictive distribution we should first downsample the posterior draws. I'll check what PyMC does in these cases. Maybe the answer is that we should move to pm.sample_posterior_predictive().

@digicosmos86
Copy link

@tomicapretto We implemented a temporary solution which just samples the posterior group of the trace object and then pass it to model.predict. Do you foresee issues with this?

@tomicapretto
Copy link
Collaborator

@tomicapretto We implemented a temporary solution which just samples the posterior group of the trace object and then pass it to model.predict. Do you foresee issues with this?

Nope, I think we could use it in Bambi. Do you have it somewhere? Feel free to open a PR, or I can open one myself. Thanks!

@digicosmos86
Copy link

@tomicapretto Sure! I'll do a PR soon. Thanks!

@tomicapretto tomicapretto added the good first issue If you want to contribute but are not sure where to get started, this issue is for you! label Feb 5, 2024
@tanishy7777
Copy link
Contributor

can I work on this? Could you elaborate what to do? @tomicapretto

@tomicapretto
Copy link
Collaborator

We want to modify this method to allow users to pass the number of draws when we obtain draws from the posterior predictive distribution (i.e. when kind="response"). Right now, it uses as many draws as draws from the posterior. Users may want to use fewer draws.

@jgyasu jgyasu linked a pull request Jan 20, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request good first issue If you want to contribute but are not sure where to get started, this issue is for you!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants