Skip to content

[MRG] DOC clarify the kernel gradient for GaussianProcesses#18115

Merged
jnothman merged 6 commits intoscikit-learn:masterfrom
rauwuckl:documentation_gaussian_process_kernel_gradient
Aug 15, 2020
Merged

[MRG] DOC clarify the kernel gradient for GaussianProcesses#18115
jnothman merged 6 commits intoscikit-learn:masterfrom
rauwuckl:documentation_gaussian_process_kernel_gradient

Conversation

@rauwuckl
Copy link
Copy Markdown
Contributor

@rauwuckl rauwuckl commented Aug 7, 2020

Reference Issues/PRs

Fixes #11581
Fixes #8393
Fixes #11116
Also see this comment

What does this implement/fix? Explain your changes.

The gradients of the kernels in the gaussian process module are computed with regard to the log-transformed hyper-parameter. So far this is not reflected clearly in the documentation and is thus confusing for people wanting to implement their own custom kernels. See for example the following issues:
#14206
#8373
#8359

Here I add 2 lines of explanation to the user guide, that specify the equation for the kernel gradient and emphasise the log-transform of the parameters. Further I add a mention of the log-transform to the doc string of the call method of existing kernels.

Any other comments?

See the discussion in this issue for a more detailed reasoning of this necessary documentation change.

@rauwuckl
Copy link
Copy Markdown
Contributor Author

rauwuckl commented Aug 7, 2020

@jnothman
@thomasjpfan

Copy link
Copy Markdown
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

Thank you for the PR @rauwuckl !

I ran into this exact issue when reviewing other kernel related code. (I also thought it was respect to hyperparamter.

I think the eval_gradient's docstrings in:

def __call__(self, X, Y=None, eval_gradient=False):
    eval_gradient : bool, default=False
        Determines whether the gradient with respect to the kernel
        hyperparameter is determined.

should be updated as well.

XREF #8373 (comment)

@rauwuckl
Copy link
Copy Markdown
Contributor Author

rauwuckl commented Aug 8, 2020

I added a commit changing it to:

   def __call__(self, X, Y=None, eval_gradient=False):
        """Return the kernel k(X, Y) and optionally its gradient....

        eval_gradient : bool, default=False
            Determines whether the gradient with respect to the log of the
            kernel hyperparameter is determined.
        """

does that look good to you @thomasjpfan ?

Copy link
Copy Markdown
Member

@thomasjpfan thomasjpfan left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you @rauwuckl !

@rauwuckl
Copy link
Copy Markdown
Contributor Author

@thomasjpfan
this is my first PR so I am unsure of the process. Do I have to do anything else to get this merged?

@thomasjpfan
Copy link
Copy Markdown
Member

We need to wait for another reviewer to approve this PR.

@rauwuckl
Copy link
Copy Markdown
Contributor Author

ping @amueller

@rauwuckl rauwuckl changed the title DOC clarify the kernel gradient for GaussianProcesses [MRG] DOC clarify the kernel gradient for GaussianProcesses Aug 14, 2020
Copy link
Copy Markdown
Member

@jnothman jnothman left a comment

Choose a reason for hiding this comment

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

Otherwise LGTM

Determines whether the gradient with respect to the kernel
hyperparameter is determined.
Determines whether the gradient with respect to the log of the
kernel hyperparameter is determined.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can we change "is determined" to "is computed" here and below, while we are at it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@jnothman sure thing. Just pushed that.

@jnothman jnothman merged commit eb7b158 into scikit-learn:master Aug 15, 2020
@jnothman
Copy link
Copy Markdown
Member

Thank you @rauwuckl

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.

Gradient of ConstantKernel is Incorrect Docstring of Gaussian processes kernel wrong about the calculation of gradient

3 participants