STOR-i / GaussianProcesses.jl

A Julia package for Gaussian Processes
https://stor-i.github.io/GaussianProcesses.jl/latest/
Other
308 stars 53 forks source link

Example Request for MeanLin #222

Closed sourish-cmi closed 1 year ago

sourish-cmi commented 1 year ago

I tried the following with MeanLin instead of MeanZero. All the examples are with MeanZero:

mLin = MeanLin();
kern = Matern(3/2,zeros(p),0.0);   # Matern 3/2 ARD kernel (note that hyperparameters are on the log scale)
gp2 = GP(X',y,mLin,kern);

It gives me the following error:

MethodError: no method matching MeanLin()
Closest candidates are:
  MeanLin(::Vector{Float64}) at /Users/.julia/packages/GaussianProcesses/kzIIW/src/means/mLin.jl:23

Stacktrace:
 [1] top-level scope
   @ In[79]:1
 [2] eval
   @ ./boot.jl:360 [inlined]
 [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)
   @ Base ./loading.jl:1116

How can I use Linear Mean function as you have in your documentation here.

maximerischard commented 1 year ago

Yes, you need to initialise MeanLin with a vector of coefficients. The length of the vector should be the number of dimensions of X.

sourish-cmi commented 1 year ago

Thanks, the following code works.

β_hat = StatsBase.coef(mod1.model)[2:1:(p+1)]
mLin = MeanLin(β_hat);
kern = Matern(3/2,zeros(p),0.0);   # Matern 3/2 ARD kernel (note that hyperparameters are on the log scale)
gp2 = GP(X',y,mLin,kern);
optimize!(gp2)

Thanks again. Closing the issue.