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

example: multidimensional HSGP #1801

Merged
merged 10 commits into from
Jun 17, 2024

Conversation

brendancooley
Copy link
Contributor

Adds an example to extend the existing HSGP tutorials (1 and 2) to multidimensional inputs.

While I was working on this I noticed that @juanitorduz contributed a really nice module with a bunch of utility functions for HSGPs. Very happy to see these making their way into numpyro. I think a natural next step would be to take on Juan's call to adapt his eigenfunctions/values implementations to the multidimensional case. I believe I have a good implementation in the notebook that I have tested for D=1 and D=2 but certainly welcome feedback from him and others in the community (@omarfsosa ?).

Perhaps before merging this I could extend the HSGP contrib module to support multidimensional inputs, and then refactor this notebook and the other HSGP tutorials to import the supporting functionality from the contrib module. Suggestions very welcome.

Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@juanitorduz
Copy link
Contributor

@brendancooley This extension is fantastic! Regarding your suggestion:

Perhaps before merging this I could extend the HSGP contrib module to support multidimensional inputs, and then refactor this notebook and the other HSGP tutorials to import the supporting functionality from the contrib module.

In my opinion, this would be the way to go! Extend the current HSGP module functions to support the multidimensional case. As we have already uni-tests in place, we could add these new cases and make sure we still support the one-dimensional case. After that we could showcase in your example notebook how to use the API.

Really exciting 🙌

@brendancooley
Copy link
Contributor Author

@brendancooley This extension is fantastic! Regarding your suggestion:

Perhaps before merging this I could extend the HSGP contrib module to support multidimensional inputs, and then refactor this notebook and the other HSGP tutorials to import the supporting functionality from the contrib module.

In my opinion, this would be the way to go! Extend the current HSGP module functions to support the multidimensional case. As we have already uni-tests in place, we could add these new cases and make sure we still support the one-dimensional case. After that we could showcase in your example notebook how to use the API.

Really exciting 🙌

Awesome, will get moving on this

@brendancooley
Copy link
Contributor Author

Converted to draft, will refactor to reflect changes in #1803 and re-open when ready

wip(hsgp_nd): writeup results for baseline, add mcmc options

wip(hsbp_nd): complete writeup

docs(numpyro): add hsgp_nd_example

wip(hsgp_nd): patch up example

wip(hsgp_nd): cleanup/re-run nb

wip(hsgp_nd): final cleanup
@brendancooley brendancooley marked this pull request as ready for review June 3, 2024 02:22
@brendancooley
Copy link
Contributor Author

@fehiepsi @juanitorduz ready for review here.

Copy link

review-notebook-app bot commented Jun 3, 2024

View / edit / reply to this conversation on ReviewNB

juanitorduz commented on 2024-06-03T08:51:49Z
----------------------------------------------------------------

Can you provide some intro before this cell to prepare the reader what to expect? :) For example, the paragraph below can be moved up (or the first part of it)


Copy link

review-notebook-app bot commented Jun 3, 2024

View / edit / reply to this conversation on ReviewNB

juanitorduz commented on 2024-06-03T08:51:50Z
----------------------------------------------------------------

Line #4.    import numpy as np

Shall we move all the imports to the first cell?


Copy link

review-notebook-app bot commented Jun 3, 2024

View / edit / reply to this conversation on ReviewNB

juanitorduz commented on 2024-06-03T08:51:51Z
----------------------------------------------------------------

Line #6.    

Again, it would be nice to leat the reader know what to expect. Something like: "Next, we implement some plotting functions to allow us visualize the data..."


Copy link

review-notebook-app bot commented Jun 3, 2024

View / edit / reply to this conversation on ReviewNB

juanitorduz commented on 2024-06-03T08:51:51Z
----------------------------------------------------------------

I think it would be nice to have the trace plots as in https://num.pyro.ai/en/stable/tutorials/hsgp_example.html and we can compare the infered parameters from netween models (the exact and approximation) and show the approximation does recover the expected parameters.


Copy link

review-notebook-app bot commented Jun 3, 2024

View / edit / reply to this conversation on ReviewNB

juanitorduz commented on 2024-06-03T08:51:52Z
----------------------------------------------------------------

The HSGP model is much better ... why do you think this is the case as compared with the exact one? Or is it just the plot?


brendancooley commented on 2024-06-03T21:02:17Z
----------------------------------------------------------------

Ah to clarify -- this is the HSGP versus the exact (not HSGP versus True). So this is just showing that their posterior predictive means line up for all data points. I will make sure I clarify, easy to see why you would think that.

@juanitorduz
Copy link
Contributor

@brendancooley This example looks great! I left some small comments and suggestions.

I would suggest a bit more content on the storyline between cells to guide a non-expert reader through the content. Not really about the HSGP approximation but more about the connection between the sections. Just a suggestion :)

@brendancooley
Copy link
Contributor Author

@brendancooley This example looks great! I left some small comments and suggestions.

I would suggest a bit more content on the storyline between cells to guide a non-expert reader through the content. Not really about the HSGP approximation but more about the connection between the sections. Just a suggestion :)

Thanks for the prompt feedback! Agree that it ended up a little terse...I'll try and fill in some words between those monstrous matplotlib functions and add some extra comparisons between the models. Will reach back when comments have been addressed.

Copy link
Contributor Author

Ah to clarify -- this is the HSGP versus the exact (not HSGP versus True). So this is just showing that their posterior predictive means line up for all data points. I will make sure I clarify, easy to see why you would think that.


View entire conversation on ReviewNB

@brendancooley
Copy link
Contributor Author

Added trace plots from arviz for both the exact model and the approximation, and a density plot to compare the approximation to the exact model. Took the time to write better expositions for each of the code blocks. Thanks to @juanitorduz for the prodding and helpful feedback.

@fehiepsi believe this is ready to go.

Copy link

review-notebook-app bot commented Jun 5, 2024

View / edit / reply to this conversation on ReviewNB

juanitorduz commented on 2024-06-05T18:41:08Z
----------------------------------------------------------------

It seems we are having some divergences, maybe you try increasting target_accept_prob to 0.9 in the fit_mcmc function as a model_karg ? We could also increase wthe num_warmup and num_samples to 1_000


@juanitorduz
Copy link
Contributor

Hey @brendancooley it looks great! I left a comment to see if we can get rid of these divergences. Besides that, it looks great!

@brendancooley
Copy link
Contributor Author

@juanitorduz bumped the target_accept_prob and switched the initialization strategy.

Number of divergences: 0

and trace plots look better.

It runs so fast that experimentation is a breeze!

Copy link
Contributor

@juanitorduz juanitorduz left a comment

Choose a reason for hiding this comment

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

Looks great! Thanks !

Copy link

review-notebook-app bot commented Jun 9, 2024

View / edit / reply to this conversation on ReviewNB

fehiepsi commented on 2024-06-09T14:48:27Z
----------------------------------------------------------------

Could you add a cell # pip install numpyro here?


brendancooley commented on 2024-06-09T16:41:17Z
----------------------------------------------------------------

done!

Copy link
Contributor Author

done!


View entire conversation on ReviewNB

Copy link
Member

@fehiepsi fehiepsi left a comment

Choose a reason for hiding this comment

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

Great tutorial, thanks @brendancooley!

Also thanks for reviewing, @juanitorduz!

@juanitorduz
Copy link
Contributor

(are we waiting for additional reviews 😄 ?)

@fehiepsi fehiepsi merged commit 40565d0 into pyro-ppl:master Jun 17, 2024
4 checks passed
@brendancooley brendancooley deleted the feat/hsgp-multidim-example branch June 17, 2024 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants