Models

GPExact

class lightgp.GPExact(kernel, mean=None, noise_var=0.1, backend=Backend.Auto, solver=Solver.Cholesky)

Exact Gaussian Process regression.

Parameters:
  • kernel – A lightgp.Kernel (possibly composed).

  • mean – A lightgp.Mean. Defaults to ZeroMean when omitted.

  • noise_var – Observation noise variance \(\sigma_n^2\).

  • backend – Compute backend. Backend.Auto selects the fastest available for the problem shape (see Backends).

  • solver – Inference method (see Solvers).

Solver complexity:

Solver

Time per fit

When to use

Cholesky

\(O(N^3)\)

\(N < 5{,}000\). Exact.

CG

\(O(N^2 k)\)

\(5{,}000 \le N < 50{,}000\). Matrix-free on GPU (no \(N \times N\) kernel matrix in memory).

SKI

\(O(N \log N \cdot k)\)

\(N > 50{,}000\) and \(D \le 3\). FFT-based.

fit(X, y) bool

Fit the GP to training data.

Parameters:
  • X – Inputs, shape (N, D), dtype float32.

  • y – Targets, shape (N,), dtype float32.

Returns:

True if the (jittered) Cholesky or CG solve succeeded.

predict(X_test) dict

Posterior mean + variance at test points.

Parameters:

X_test – Test inputs, shape (M, D), float32.

Returns:

dict with keys "mean" (M,) and "var" (M,).

optimize(steps=100, lr=0.05, verbose=False) bool

Adam optimizer on the flat log-hyperparameter vector [kernel.params, log_noise, mean.params]. With the new Kernel API the gradient is computed by central finite differences to support arbitrary compositions.

log_marginal_likelihood() float

The (negative-Hutchinson-estimated when in CG mode) log marginal likelihood under the current hyperparameters.

fitted() bool

True once a successful fit() has been called.

GPSparse

class lightgp.GPSparse(length_scale=1.0, signal_var=1.0, noise_var=0.1, backend=Backend.Auto)

Sparse GP regression using Titsias’ variational free energy (VFE) bound, 2009. Scales to \(N \gtrsim 10^5\) with \(M\) inducing points.

Parameters:
  • length_scale – RBF length scale (legacy API; the Kernel-object refactor for GPSparse is on the roadmap).

  • signal_var – RBF signal variance.

  • noise_var – Observation noise variance.

  • backend – Compute backend.

fit(X, y, num_inducing=100) bool

Fit with M inducing points (initialized by farthest-point sampling).

predict(X_test) dict

Same return shape as GPExact.predict().

log_marginal_likelihood() float

VFE bound at the current state.

fitted() bool