friedrich/
lib.rs

1//! # Friedrich : Gaussian Process Regression
2//!
3//! This library implements [Gaussian Process Regression](https://en.wikipedia.org/wiki/Gaussian_process) in Rust.
4//! Our goal is to provide a building block for other algorithms (such as [Bayesian Optimization](https://en.wikipedia.org/wiki/Bayesian_optimization)).
5//!
6//! 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.
7//! Furthermore, they can handle non-linear phenomenons, take uncertainty on the inputs into account and encode a prior on the output.
8//!
9//! 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.
10//!
11//! However, the `o(n^3)` complexity of the algorithm makes the classical implementation unsuitable for large training datasets.
12//!
13//! ## Functionalities
14//!
15//! This implementation lets you:
16//!
17//! - Define a gaussian process with default parameters or using the builder pattern.
18//! - Train it on multidimensional data.
19//! - Fit the parameters (kernel, prior and noise) on the training data.
20//! - Add additional samples efficiently (`O(n^2)`) and refit the process.
21//! - Predict the mean, variance and covariance matrix for given inputs.
22//! - Sample the distribution at a given position.
23//! - Save and load a trained model with [serde](https://serde.rs/).
24//!
25//! ## Inputs
26//!
27//! Most methods of this library can currently work with the following `input -> output` pairs :
28//!
29//! Input | Output | Description
30//! ---|---|---
31//! [`Vec<f64>`] | [`f64`] | A single, multidimensional, sample.
32//! [`Vec<Vec<f64>>`] | [`Vec<f64>`] | Each inner vector is a training sample.
33//! [`DMatrix<f64>`](https://docs.rs/nalgebra/0.29/nalgebra/base/type.DMatrix.html) | [`DVector<f64>`](https://docs.rs/nalgebra/0.29/nalgebra/base/type.DVector.html) | Using a [nalgebra](https://www.nalgebra.org/) matrix with one row per sample.
34//! [`Array1<f64>`](https://docs.rs/ndarray/0.15/ndarray/type.Array1.html) | [`f64`] | A single sample stored in a [ndarray](https://crates.io/crates/ndarray) array (using the `friedrich_ndarray` feature).
35//! [`Array2<f64>`](https://docs.rs/ndarray/0.15/ndarray/type.Array2.html) | [`Array1<f64>`](https://docs.rs/ndarray/0.15/ndarray/type.Array1.html) | Each row is a sample (using the `friedrich_ndarray` feature).
36//!
37//! See the [`Input`] trait if you want to add you own input type.
38//!
39mod algebra;
40mod conversion;
41pub mod gaussian_process;
42mod parameters;
43pub use algebra::{SMatrix, SRowVector, SVector};
44pub use conversion::Input;
45pub use parameters::*;