Skip to content

Commit 6eef6fb

Browse files
committed
Move some text, add DisplayAs
1 parent feb63fe commit 6eef6fb

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

examples/features/Project.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[deps]
2-
AbstractGPs = "99985d1d-32ba-4be9-9821-2ec096f28918"
3-
AbstractGPsMakie = "7834405d-1089-4985-bd30-732a30b92057"
42
CairoMakie = "13f3f980-e62b-5c42-98c6-ff1f3baf88f0"
3+
DisplayAs = "0b91fe84-8a4c-11e9-3e1d-67c38462b6d6"
54
KernelSpectralDensities = "027d52a2-76e5-4228-9bfe-bc7e0f5a8348"
65
Literate = "98b081ad-f1c9-55d3-8b20-4c87d4299306"
76
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"

examples/features/script.jl

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,31 +9,20 @@
99
using KernelSpectralDensities
1010
using AbstractGPs
1111
using StatsBase
12-
# using LinearAlgebra
13-
using AbstractGPsMakie
1412
using CairoMakie
13+
using DisplayAs #hide
1514

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

20-
ker = SqExponentialKernel()
21-
S = SpectralDensity(ker, 1)
22-
23-
gp = GP(ker)
24-
25-
# We can also plot this GP using AbstractGPsMakie.jl, but
26-
# we don't see very much, since we have a simple GP with
27-
# zero mean and a variance of 1.
28-
f = plot(0:0.1:1, gp; size=(600, 400))
29-
DisplayAs.PNG(f) #hide #md
30-
31-
# ## Random Fourier Features
20+
# A special class of feature functions are "random Fourier features", derived from
21+
# the Fourier transform, which we saw in add link from other example.
3222
# KernelSpectralDensities implements two types of random Fourier features,
3323
# `ShiftedRFF` and `DoubleRFF`.
34-
# A feature function projects its input into a higher-dimensional "features" space.,
3524

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

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

0 commit comments

Comments
 (0)