Crate friedrich

source ·
Expand description

Friedrich : Gaussian Process Regression

This library implements Gaussian Process Regression in Rust. Our goal is to provide a building block for other algorithms (such as Bayesian Optimization).

Gaussian process have both the ability to extract a lot of information from their training data and to return a prediction and an uncertainty on their prediction. Furthermore, they can handle non-linear phenomenons, take uncertainty on the inputs into account and encode a prior on the output.

All of those properties make them an algorithm of choice to perform regression when data is scarce or when having uncertainty bars on the output is a desirable property.

However, the o(n^3) complexity of the algorithm makes the classical implementation unsuitable for large training datasets.

Functionalities

This implementation lets you:

  • Define a gaussian process with default parameters or using the builder pattern.
  • Train it on multidimensional data.
  • Fit the parameters (kernel, prior and noise) on the training data.
  • Add additional samples efficiently (O(n^2)) and refit the process.
  • Predict the mean, variance and covariance matrix for given inputs.
  • Sample the distribution at a given position.
  • Save and load a trained model with serde.

Inputs

Most methods of this library can currently work with the following input -> output pairs :

InputOutputDescription
Vec<f64>f64A single, multidimensional, sample.
Vec<Vec<f64>>Vec<f64>Each inner vector is a training sample.
DMatrix<f64>DVector<f64>Using a nalgebra matrix with one row per sample.
Array1<f64>f64A single sample stored in a ndarray array (using the friedrich_ndarray feature).
Array2<f64>Array1<f64>Each row is a sample (using the friedrich_ndarray feature).

See the Input trait if you want to add you own input type.

Modules

Gaussian process
Kernels
Prior

Traits

Implemented by Input -> Output type pairs

Type Definitions

matrix with arbitrary storage S: Storage<f64, Dynamic, Dynamic>
row vector with arbitrary storage S: Storage<f64, U1, Dynamic>
vector with arbitrary storage S: Storage<f64, Dynamic, U1>