Skip to content

Add metric field #286

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

Merged
merged 7 commits into from
May 15, 2021
Merged

Add metric field #286

merged 7 commits into from
May 15, 2021

Conversation

devmotion
Copy link
Member

@devmotion devmotion commented May 7, 2021

When I updated some of my calibration packages recently, it was quite annoying to see that I had different multiple exponential kernels just because I wanted to use different metrics. So in this PR I tried to fix #273 (at least to some extent) and added a metric field to some of the kernels.

Since the change is breaking, I also removed the deprecations in a second commit.

@torfjelde might be interested in this PR 🙂

@willtebbutt
Copy link
Member

@devmotion this is nice. Could you elaborate on what aspect of it is breaking? Seems to me that users shouldn't see any obvious difference.

@devmotion
Copy link
Member Author

The types change. E.g., currently SqExponentialKernel is a concrete type whereas with this PR it will be an abstract type since it has a type parameter now. This can break dispatches. And actually it broke our tests where we check k isa KernelProduct{Tuple{SqExponentialKernel,CosineKernel}}.

@willtebbutt
Copy link
Member

Ah okay, makes sense.

@willtebbutt
Copy link
Member

I have no objections to this, but I'll let @theogf review and approve.

@devmotion devmotion requested a review from theogf May 12, 2021 12:35
Copy link
Member

@theogf theogf left a comment

Choose a reason for hiding this comment

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

Overall it looks good I just have a comment for the docstrings. The |x-x'|, is a bit specific, is there any guarantee that the metric is always based on the vector differences?
Maybe another notation might be more explicit?

```math
k(x, x') = \\exp\\bigg(- \\frac{\\|x - x'\\|_2^2}{2}\\bigg).
k(x, x') = \\exp\\bigg(- \\frac{\\|x - x'\\|^2}{2}\\bigg).
Copy link
Member

Choose a reason for hiding this comment

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

Should |x - x'| be replaced entirely by something more abstract like d(x, x')?

This comment applies generally to the other kernels in general

@devmotion
Copy link
Member Author

Good idea! I'll generalize the docstrings, I don't think it should be restricted to this form.

@devmotion
Copy link
Member Author

I updated the docstrings.

@theogf
Copy link
Member

theogf commented May 13, 2021

Nice! Maybe one last thing would be to write for each kernel explicitly "by default d is the Euclidean metric" for example

@devmotion
Copy link
Member Author

In the section with the mathematical definition? I assumed it would be sufficient to mention it in the function signature in the docstring, similar to other parameters whose default values are also not mentioned in the definition.

@theogf
Copy link
Member

theogf commented May 13, 2021

Yeah kind of below the mathematical definition so people who are not so familiar with kernels can have an idea how they "usually" look like.

@devmotion
Copy link
Member Author

I added a note that explains that the default choice for d is the Euclidean metric.

@devmotion
Copy link
Member Author

Test failures with Julia nightly are unrelated.

@devmotion devmotion merged commit a827302 into master May 15, 2021
@devmotion devmotion deleted the dw/metric branch May 15, 2021 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add back metric in type for stationary kernels
3 participants