Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add some examples #20

Merged
merged 33 commits into from
Feb 22, 2025
Merged
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9bc3a16
Try first example with GP docs
Crown421 Feb 13, 2025
52ad955
Need to remove GP docs as explicit dependency
Crown421 Feb 13, 2025
6616019
Cleanup
Crown421 Feb 13, 2025
8657c72
Show different kernels
Crown421 Feb 13, 2025
c8cbbaf
Try to reduce size of rendered notebook
Crown421 Feb 13, 2025
9b6d491
Another try, now with png setting
Crown421 Feb 13, 2025
a55eceb
Try with DisplayAs
Crown421 Feb 13, 2025
52393ad
Adjust filtering
Crown421 Feb 13, 2025
3b4ec04
Change filter
Crown421 Feb 13, 2025
7f1df41
One more small change
Crown421 Feb 13, 2025
8fc375a
Now hiding without the space
Crown421 Feb 13, 2025
b08ace3
Small tooltip change and first part of feature functions script
Crown421 Feb 19, 2025
feb63fe
Forgot to add literate
Crown421 Feb 19, 2025
6eef6fb
Move some text, add DisplayAs
Crown421 Feb 19, 2025
ffa8c0d
Forgot to remove a package
Crown421 Feb 19, 2025
1314a73
More code I forgot....
Crown421 Feb 19, 2025
d40ae26
Small text changes
Crown421 Feb 19, 2025
af6b049
Forgot AbstractGPsMakie, smaller rewrites
Crown421 Feb 19, 2025
41bd745
Add kernel trick
Crown421 Feb 20, 2025
bc4629c
Add comparison
Crown421 Feb 20, 2025
ef9de01
Comparison plot
Crown421 Feb 20, 2025
4aec40c
Small updates, attempt at linking
Crown421 Feb 20, 2025
6b9f8f3
Small tweaks
Crown421 Feb 20, 2025
68e01e0
Try named refs
Crown421 Feb 20, 2025
5e48422
Explicit order and small doc changes
Crown421 Feb 21, 2025
d248567
prior GP example
Crown421 Feb 21, 2025
ed4d0dd
Changing headers
Crown421 Feb 21, 2025
2ff120c
Some formatting changes
Crown421 Feb 21, 2025
098987b
Change printing
Crown421 Feb 21, 2025
a096d83
Some minor format changes
Crown421 Feb 21, 2025
c37ff76
Final edits
Crown421 Feb 21, 2025
38d5f70
Try different eval function
Crown421 Feb 21, 2025
5da79a2
Full transition of result printing
Crown421 Feb 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move some text, add DisplayAs
  • Loading branch information
Crown421 committed Feb 19, 2025
commit 6eef6fb901b15a2143f36c66fbf79f6557c365f5
3 changes: 1 addition & 2 deletions examples/features/Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[deps]
AbstractGPs = "99985d1d-32ba-4be9-9821-2ec096f28918"
AbstractGPsMakie = "7834405d-1089-4985-bd30-732a30b92057"
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
DisplayAs = "0b91fe84-8a4c-11e9-3e1d-67c38462b6d6"
KernelSpectralDensities = "027d52a2-76e5-4228-9bfe-bc7e0f5a8348"
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
31 changes: 11 additions & 20 deletions examples/features/script.jl
Original file line number Diff line number Diff line change
@@ -9,31 +9,20 @@
using KernelSpectralDensities
using AbstractGPs
using StatsBase
# using LinearAlgebra
using AbstractGPsMakie
using CairoMakie
using DisplayAs #hide

# ## Intro
# We use the AbstractGPs package to define a stationary GP prior,
# in other words, a GP that has not been conditioned on data yet.
# In general, feature functions allow us to project an input into a higher-dimensional space,
# which is useful for a variety of tasks.
# For example, we can use them to approximate a kernel using the "kernel trick".

ker = SqExponentialKernel()
S = SpectralDensity(ker, 1)

gp = GP(ker)

# We can also plot this GP using AbstractGPsMakie.jl, but
# we don't see very much, since we have a simple GP with
# zero mean and a variance of 1.
f = plot(0:0.1:1, gp; size=(600, 400))
DisplayAs.PNG(f) #hide #md

# ## Random Fourier Features
# A special class of feature functions are "random Fourier features", derived from
# the Fourier transform, which we saw in add link from other example.
# KernelSpectralDensities implements two types of random Fourier features,
# `ShiftedRFF` and `DoubleRFF`.
# A feature function projects its input into a higher-dimensional "features" space.,

# ### ShiftedRFF
# ## ShiftedRFF
# The `ShiftedRFF` feature function is somewhat more common, and has
# been used in papers such as [Efficiently sampling functions from Gaussian process posteriors](https://proceedings.mlr.press/v119/wilson20a.html).
#
@@ -61,7 +50,7 @@ axislegend(ax; position=:ct)
f
DisplayAs.PNG(f) #hide #md

# ### DoubleRFF
# ## DoubleRFF
# The `DoubleRFF` feature function is less common, but is theoretically
# equivalent to the `ShiftedRFF` feature function.
#
@@ -86,4 +75,6 @@ ax = Axis(f[1, 1]; xlabel="x", ylabel="rff(x)", title="Double RFF")
series!(ax, x, reduce(hcat, drff.(x)); labels=["drff $i" for i in 1:4])
axislegend(ax; position=:ct)
f
DisplayAs.PNG(f) #hide #md
DisplayAs.PNG(f) #hide #md

# ## Approximating a kernel
Loading