Skip to content

add gibbskernel example to prior example script #375

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

Conversation

Cyberface
Copy link
Contributor

Summary

Adding an example how to use the Gibbs Kernel in the prior example.
The Gibbs kernel has a lengthscale function as it's parameter.
I just chose a simple function for demonstration purposes i.e. l(x) = exp(sin(x)).

Proposed changes

  • Adding an example to examples/gaussian-process-priors/script.jl

What alternatives have you considered?

Could make a separate example and will probably do that when I have a working version of the Gibbs kernel that also learns the lengthscale function.

Breaking changes

None

@@ -120,6 +120,7 @@ kernels = [
LinearKernel(),
compose(PeriodicKernel(), ScaleTransform(0.2)),
NeuralNetworkKernel(),
GibbsKernel(x -> exp(sin.(x))),
Copy link
Member

Choose a reason for hiding this comment

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

Usually we prefer the keyword argument constructor since it is a bit clearer. You can also simplify the lengthscale function a bit (broadcasting is only useful if x are vectors - in which case exp(sin.(x)) would fail though):

Suggested change
GibbsKernel(x -> exp(sin.(x))),
GibbsKernel(; lengthscale=exp sin),

Copy link
Member

Choose a reason for hiding this comment

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

I think we should generally handle vectors so something like exp(sum(sin, x)) maybe?

Copy link
Member

Choose a reason for hiding this comment

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

It seemed the example only deals with scalar inputs but maybe I didn't check it carefully enough. If vectors occur as inputs, then I agree something like x -> exp(sum(sin, x)) or x -> sum(exp ∘ sin, x) should be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks both for the helpful information and suggestions. I went with x -> sum(exp ∘ sin, x) and checked locally that it works in a notebook so hopefully the CI will be happy.

@Cyberface
Copy link
Contributor Author

Can this be merged?

@theogf
Copy link
Member

theogf commented Oct 20, 2021

@Cyberface, unfortunately since this is from a fork we cannot visualize the result... Could you run the docs locally and post here a screenshot of the resulting GP prior? :)

@Cyberface
Copy link
Contributor Author

@theogf thanks for letting me know what to do, I managed to build the docs using the README in the docs dir.

The GP prior example page is quite long but there should only be two difference.

  1. in the kernels list where I've add GibbsKernel

Screenshot 2021-10-26 at 12 41 37

  1. in the output where the final plot shows the GibbsKernel in action

Screenshot 2021-10-26 at 12 40 46

@theogf
Copy link
Member

theogf commented Oct 26, 2021

That looks great! Thanks for the addition

@codecov
Copy link

codecov bot commented Oct 26, 2021

Codecov Report

Merging #375 (b108dac) into master (cc2289c) will decrease coverage by 19.68%.
The diff coverage is n/a.

Impacted file tree graph

@@             Coverage Diff             @@
##           master     #375       +/-   ##
===========================================
- Coverage   89.23%   69.54%   -19.69%     
===========================================
  Files          52       52               
  Lines        1198     1192        -6     
===========================================
- Hits         1069      829      -240     
- Misses        129      363      +234     
Impacted Files Coverage Δ
src/basekernels/gabor.jl 0.00% <0.00%> (-100.00%) ⬇️
src/basekernels/cosine.jl 0.00% <0.00%> (-100.00%) ⬇️
src/basekernels/nn.jl 0.00% <0.00%> (-97.62%) ⬇️
src/basekernels/sm.jl 0.00% <0.00%> (-94.12%) ⬇️
src/basekernels/wiener.jl 0.00% <0.00%> (-92.86%) ⬇️
src/basekernels/piecewisepolynomial.jl 0.00% <0.00%> (-89.48%) ⬇️
src/basekernels/rational.jl 13.33% <0.00%> (-80.00%) ⬇️
src/basekernels/exponentiated.jl 0.00% <0.00%> (-80.00%) ⬇️
src/basekernels/matern.jl 20.83% <0.00%> (-75.17%) ⬇️
src/basekernels/constant.jl 25.00% <0.00%> (-75.00%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update cc2289c...b108dac. Read the comment docs.

@theogf theogf merged commit 8e3e5a8 into JuliaGaussianProcesses:master Oct 26, 2021
@Cyberface Cyberface deleted the add-gibbskernel-to-prior-example branch October 27, 2021 18:21
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.

3 participants