pub struct GaussianProcess { /* private fields */ }Expand description
Gaussian Process (GP) surrogate model for function approximation.
Provides posterior mean and variance predictions at query points using Cholesky-based computations. Supports hyperparameter optimization via NLML.
Implementations§
Source§impl GaussianProcess
impl GaussianProcess
Sourcepub fn new(kernel_type: KernelType, noise_variance: f64) -> Self
pub fn new(kernel_type: KernelType, noise_variance: f64) -> Self
Create a new unfitted Gaussian Process with the given kernel and noise variance.
Sourcepub fn fit(&mut self, x: &[Vec<f64>], y: &[f64]) -> Result<()>
pub fn fit(&mut self, x: &[Vec<f64>], y: &[f64]) -> Result<()>
Fit the GP model to training data (normalizes, computes kernel, Cholesky, alpha).
Sourcepub fn predict(&self, x_new: &[f64]) -> Result<(f64, f64)>
pub fn predict(&self, x_new: &[f64]) -> Result<(f64, f64)>
Predict the posterior mean and variance at a new point (de-normalized).
Sourcepub fn predict_batch(&self, x_new: &[Vec<f64>]) -> Result<(Vec<f64>, Vec<f64>)>
pub fn predict_batch(&self, x_new: &[Vec<f64>]) -> Result<(Vec<f64>, Vec<f64>)>
Predict mean and variance for multiple points.
Sourcepub fn negative_log_marginal_likelihood(&self) -> Result<f64>
pub fn negative_log_marginal_likelihood(&self) -> Result<f64>
Compute the negative log marginal likelihood (for hyperparameter optimization).
Sourcepub fn optimize_hyperparameters(
&mut self,
x: &[Vec<f64>],
y: &[f64],
n_restarts: usize,
) -> Result<()>
pub fn optimize_hyperparameters( &mut self, x: &[Vec<f64>], y: &[f64], n_restarts: usize, ) -> Result<()>
Optimize kernel hyperparameters via multi-start coordinate descent on NLML.
Sourcepub fn sample_posterior(
&self,
x_points: &[Vec<f64>],
rng: &mut impl Rng,
) -> Result<Vec<f64>>
pub fn sample_posterior( &self, x_points: &[Vec<f64>], rng: &mut impl Rng, ) -> Result<Vec<f64>>
Sample from the GP posterior at the given points (for Thompson Sampling).
Sourcepub fn kernel_type(&self) -> &KernelType
pub fn kernel_type(&self) -> &KernelType
Get the current kernel type.
Sourcepub fn length_scale(&self) -> f64
pub fn length_scale(&self) -> f64
Get the current length scale.
Sourcepub fn signal_variance(&self) -> f64
pub fn signal_variance(&self) -> f64
Get the current signal variance.
Trait Implementations§
Source§impl Clone for GaussianProcess
impl Clone for GaussianProcess
Source§fn clone(&self) -> GaussianProcess
fn clone(&self) -> GaussianProcess
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for GaussianProcess
impl RefUnwindSafe for GaussianProcess
impl Send for GaussianProcess
impl Sync for GaussianProcess
impl Unpin for GaussianProcess
impl UnsafeUnpin for GaussianProcess
impl UnwindSafe for GaussianProcess
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.