pulsatrix
Loading...
Searching...
No Matches
pulsatrix::GaussianProcessRegressor Class Reference

A fitted (or queryable-before-fitting-throws) Gaussian Process regressor with a squared-exponential kernel: k(x, x') = sigma_f^2 * exp(-||x - x'||^2 / (2 * length_scale^2)), plus additive observation noise (a small noise_variance is also standard GP practice purely as numerical "jitter" to keep the kernel matrix well-conditioned, independent of whether the underlying objective is actually noisy). More...

#include <gaussian_process.hpp>

Classes

struct  Posterior
 A posterior prediction: mean and variance at one query point. More...
 

Public Member Functions

 GaussianProcessRegressor (float sigma_f, float length_scale, float noise_variance)
 
void Fit (std::vector< std::vector< float > > inputs, std::vector< float > targets)
 Fits the GP to (inputs[i], targets[i]) observation pairs – computes and solves the training kernel matrix once; Predict (below) reuses this fit.
 
Posterior Predict (const std::vector< float > &x) const
 Predicts the posterior mean/variance at x, given the data passed to Fit.
 

Detailed Description

A fitted (or queryable-before-fitting-throws) Gaussian Process regressor with a squared-exponential kernel: k(x, x') = sigma_f^2 * exp(-||x - x'||^2 / (2 * length_scale^2)), plus additive observation noise (a small noise_variance is also standard GP practice purely as numerical "jitter" to keep the kernel matrix well-conditioned, independent of whether the underlying objective is actually noisy).

Constructor & Destructor Documentation

◆ GaussianProcessRegressor()

pulsatrix::GaussianProcessRegressor::GaussianProcessRegressor ( float  sigma_f,
float  length_scale,
float  noise_variance 
)
inline
Parameters
sigma_fKernel signal variance (prior variance at any single point, before conditioning on data).
length_scaleKernel length scale – how far apart two points must be before the kernel considers them roughly uncorrelated.
noise_varianceAdded to the kernel matrix's diagonal. Must be non-negative.
Exceptions
std::invalid_argumentif sigma_f <= 0, length_scale <= 0, or noise_variance < 0.

Member Function Documentation

◆ Fit()

void pulsatrix::GaussianProcessRegressor::Fit ( std::vector< std::vector< float > >  inputs,
std::vector< float >  targets 
)
inline

Fits the GP to (inputs[i], targets[i]) observation pairs – computes and solves the training kernel matrix once; Predict (below) reuses this fit.

Exceptions
std::invalid_argumentif inputs is empty, inputs.size() != targets.size(), or inputs' rows are not all the same dimension.
std::runtime_error– propagated from SolveLinearSystem if the kernel matrix is near-singular (e.g. duplicate input points with noise_variance == 0).

◆ Predict()

Posterior pulsatrix::GaussianProcessRegressor::Predict ( const std::vector< float > &  x) const
inline

Predicts the posterior mean/variance at x, given the data passed to Fit.

Exceptions
std::runtime_errorif Fit has not been called yet.
std::invalid_argumentif x's dimension doesn't match the training inputs'.
std::runtime_error– propagated from SolveLinearSystem if the kernel matrix is near-singular.
Note
variance is clamped to >= 0 – floating-point rounding can otherwise make it a tiny negative number exactly at (or extremely near) a training point, which is not a meaningful negative variance, just accumulated rounding error.

The documentation for this class was generated from the following file: