GaussianProcessClassifier<T>

Models & Types · AiDotNet.GaussianProcesses

Implements a Gaussian Process Classifier using Laplace approximation for probabilistic classification.

Implements: IGaussianProcessClassifier<T>

For Beginners

A Gaussian Process Classifier (GPC) is a powerful machine learning method that not only classifies data but also tells you how confident it is about each prediction.

Imagine you’re building a spam filter:

  • A regular classifier might say: “This email is spam”
  • A GP classifier says: “This email is 95% likely to be spam, and I’m quite confident about this”

How does it work?

  1. It learns a “latent function” - a hidden score for each point in your data space
  2. This score is passed through a sigmoid function to get a probability
  3. The Laplace approximation helps us handle the mathematical complexity

The Laplace Approximation:

  • GP classification doesn’t have a nice closed-form solution like GP regression
  • The Laplace approximation finds the most likely values (the “mode”) of the latent function
  • It then approximates the posterior as a Gaussian centered at this mode
  • This gives us uncertainty estimates even though the true posterior is non-Gaussian

When to use GP Classification:

  • When you need probability estimates, not just class labels
  • When you have small to medium-sized datasets (up to a few thousand points)
  • When uncertainty quantification is important (medical diagnosis, risk assessment)
  • When your decision boundary might be non-linear

Limitations:

  • Scales cubically O(n³) with dataset size due to matrix operations
  • For larger datasets, consider Sparse GP Classification (SVGP)

Constructors

Constructor Summary
GaussianProcessClassifier(IKernelFunction<T> kernel, MatrixDecompositionType decompositionType, int maxIterations, double tolerance) Initializes a new instance of the GaussianProcessClassifier class.

Properties

Property Summary
int NumClasses { get; }

Methods

Method Summary
Matrix<T> PredictProbabilities(Matrix<T> X)
T GetLogMarginalLikelihood()
ValueTuple<int, T, T> Predict(Vector<T> x)
void Fit(Matrix<T> X, Vector<T> y) Trains the Gaussian Process classifier on the provided data using Laplace approximation.
void UpdateKernel(IKernelFunction<T> kernel)