pyro-ppl / pyro

Deep universal probabilistic programming with Python and PyTorch
http://pyro.ai
Apache License 2.0
8.53k stars 984 forks source link

Port NumPyro introductory examples to Pyro #2995

Open eb8680 opened 2 years ago

eb8680 commented 2 years ago

NumPyro now has several excellent introductory examples with no direct counterparts in Pyro. Porting one of these to Pyro would be a great way for someone to simultaneously learn more about Bayesian data analysis and make a valuable open source contribution.

If you are reading this and want to give one of them a try, please leave a comment here so that other people are aware of your work and so we can help you get started!

Bonus points if you can modify an example to use variational inference with Pyro's autoguides rather than MCMC while obtaining similar results.

List of examples:

arijeetchatterjee commented 2 years ago

I can start working on the Bayesian Regression example if no one else is working on it.

eb8680 commented 2 years ago

@arijc76 great, go for it!

arijeetchatterjee commented 2 years ago

@eb8680 - I am nearly done with the regression example. However, there is one issue. I am unable to figure out why the custom predict function is not showing the same results as the Predictive utility. Since I can't use vmap as per the NumPyro example, I am using a for loop. I think it might be a problem with the seed. I'd appreciate any suggestion on this. Also, I have added variational inference with an autoguide for model 1. Here's a link to my git repo where can take a look - https://github.com/arijc76/prob-ml/blob/main/bayesian_regression_pyro.ipynb Let me know any feedback. Thanks.

eb8680 commented 2 years ago

Hi @arijc76, nice work! The reason you are seeing different values in your custom predict function is that it is drawing fresh samples for the random variable obs, as expected. If you'd like the values to be more similar, you could draw more samples (1000, say). You can use pyro.plate to vectorize sampling, as in this section of the Pyro intro tutorial.

Whenever you're ready, feel free to open a pull request with your notebook so we can review it in more detail.

arijeetchatterjee commented 2 years ago

Thanks @eb8680. The results are more similar now after following your suggestion. I will open a pull request with the notebook. After reviewing the Contributing.md, I wanted to clarify if it is sufficient to follow the steps mentioned in the Testing Tutorials section or is there anything else that I should be checking before submitting the pull request. Thanks again.

eb8680 commented 2 years ago

@arijc76 that should be fine - we can help you get CI tests working in the PR.

JamesTrick commented 2 years ago

I'm keen to contribute the Bayesian Hierarchical Regression tutorial, I've already ported it in the past so will clean it up and try variational inference with it.

eb8680 commented 2 years ago

@JamesTrick sorry for the delay, that sounds great! Please let us know if you need any help getting started.

arijeetchatterjee commented 2 years ago

Hi @eb8680 Since I'm nearly done with the Bayesian Regression Using NumPyro example, I can work on the Bayesian Imputation example if that's ok.

willtai commented 2 years ago

Hi there @arijc76 , is this issue still available for contribution? I am keen to give Bayesian Imputation a try

arijeetchatterjee commented 2 years ago

Hi @willtai , Yes it's available. I am not working on the Bayesian Imputation example.

nikolageorgiev2000 commented 11 months ago

If the Bayesian imputation task is still open, I'd like to pick it up. @willtai @arijeetchatterjee