-
-
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
Modifying cartesian product to allow for >2D input arrays #4482
Conversation
I didn't run the tests locally here - I'll edit and fix as appropriate so that it passes. |
I checked out the branch and tried the gist, it works great.
Definitely agree. Maybe a test of the new functionality with a 2D X input could be added, or existing test modified? |
Thanks for taking a look at this! I just added a new test which covers the usage of a 2D input as well as a 1D length-1 input. |
) | ||
auto_cart = cartesian(a, b, c) | ||
np.testing.assert_array_almost_equal(manual_cartesian, auto_cart) | ||
|
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.
I would think that assert_array_equal
is sufficient here (no almost). I noticed the other test_cartesian
does this so they should both be fixed
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.
Good point - those assertions have been changed.
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.
LGTM
From your example gist my understanding is that the function you changed plays a role for the kron_Xs
in the marginal likelihood?
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.
Ah sorry one more thing: Please add a line to the release notes.
Thanks for adding the release note!
Yes, it turns out that most of the functionality in the marginal likelihood bit was working fine - the only change was in how the input coordinates are preprocessed via |
Modifying cartesian product to allow for >2D input arrays (pymc-devs#4482)
…mc-devs#4482)" This reverts commit 47b3658.
Currently, using the implementation of MarginalKron for structured Gaussian processes is limited by an inability to initialize the GP for input arrays for the Kronecker product which have more than 1 dimension. For example, creating a Kronecker GP with a 2D spatial covariance kernel added to a 1D temporal covariance kernel is not possible while adding a 1D spatial to a 1D temporal kernel is possible. This issue limits the utility of the Kronecker GP from being used in arguably its most suitable use case (independent space/time covariance kernels). To recreate this issue, see this gist.
The main change to the function
cartesian
is to first create a cartesian product of integer vectors, and then use these to index into the input arrays instead.