JuliaGaussianProcesses / Stheno.jl

Probabilistic Programming with Gaussian processes in Julia
Other
340 stars 26 forks source link

1-Dimensional Euclidean Space example doesn't work #186

Closed troyrock closed 2 years ago

troyrock commented 3 years ago

From the documentation:

1-Dimensional Euclidean Space When constructing a GP whose domain is the real-line, for example when using a GP to solve some kind of time-series problem, it is sufficient to work with Vector{<:Real}s of inputs. As such, the following is completely valid:

using Stheno: GPC
f = GP(EQ(), GPC())  
x = randn(10)
f(x)

On the second line, I'm getting: > UndefVarError: EQ not defined.

willtebbutt commented 3 years ago

Damn, that looks to be outdated. Where did you find this example?

troyrock commented 3 years ago

https://juliagaussianprocesses.github.io/Stheno.jl/stable/input_types/

devmotion commented 3 years ago

This is an outdated documentation, it seems for the current release no stable documentation exists. I opened a PR that updates the Github actions: https://github.com/JuliaGaussianProcesses/Stheno.jl/pull/188

willtebbutt commented 3 years ago

Thanks @devmotion . Do you recall how we were able to get banners indicating outdated docs in other repos?

devmotion commented 3 years ago

It should work automatically for builds created with Documenter >= 0.27, and for old versions one can use https://juliadocs.github.io/Documenter.jl/stable/lib/public/#DocumenterTools.OutdatedWarning.generate.

vikram-s-narayan commented 2 years ago

@willtebbutt could you please suggest a workaround or equivalent for the line f = GP(EQ(), GPC()) which throws the error UndefVarError: EQ not defined ?

Thanks :)

willtebbutt commented 2 years ago

Hi @vikram-s-narayan -- could you point me towards where you've found this particular line of code? I thought I had got rid of all of the old examples!

vikram-s-narayan commented 2 years ago

@willtebbutt - these are some places where I found references to EQ() ... https://juliahub.com/ui/Packages/Stheno/sVmvC/0.6.14 https://docs.juliahub.com/Stheno/sVmvC/0.6.14/internals/

I realise now that there are updated versions. However, these are the first few pages that showed up on Google search for me.

I stumbled on this issue because I am trying to fix some breaking code in Surrogates.jl

Also, do you have any pointers as to how I can update the following piece of code to play nicely with Stheno v0.8:

"""
SthenoKriging(x::X, y::Y, GP::Stheno.GP=Stheno.GP(Stheno.EQ(), Stheno.GPC()), σ²=1e-18)
Returns a Kriging (or Gaussian process) surrogate conditioned on the data points `x` and `y`.
The `GP` is the base Gaussian process defined with Stheno.
# Arguments
- `x::X`: Vector containing the observation points
- `y::Y`: Vector containing the observed points
- `GP::Stheno.GP`: The base Gaussian process used to condition over. A simple prior is
provided as default. If there are multiple observation dimensions, a `Tuple` of Gaussian
processes can be passed, otherwise the same process is used across all dimensions.
- `σ²`=1e-18: Variance of the observation noise, default is equivalent to no noise
"""

function SthenoKriging(x, y, gp::Stheno.AbstractGP=Stheno.GP(Stheno.EQ(), Stheno.GPC()), σ²=1e-18)
    gpc = gp.gpc
    gps = ntuple(i -> Stheno.GP(Stheno.EQ(), gpc), length(y[1]))

    return SthenoKriging(x, y, gps, σ²)
end

Any tips would be super helpful :)

willtebbutt commented 2 years ago

The core of the change is that

gpc = GPC()
GP(EQ(), gpc)

became

gpc = GPC()
wrap(GP(SEKernel()), gpc)

in 0.8 (had to happen for a variety of reasons). Unpacking this:

  1. EQ -> SEKernel (Stheno uses KernelFunctions' kernels now),
  2. Stheno uses AbstractGPs' GP type, and wraps it to give it the tracking info needed.
vikram-s-narayan commented 2 years ago

Awesome! Thank you so much!

willtebbutt commented 2 years ago

Np, thanks for reminding me that this wasn't fixed. I've utilised @devmotion 's suggestion above and modified the gh-pages branches to display outdated warnings on the docs, so I'm going to close this now. Please re-open if this turns out to still be a problem.