pub struct SparseSpectrumGaussianProcessRegressor {
pub kernel: Box<dyn Kernel>,
pub num_spectral_points: usize,
pub spectral_density_threshold: f64,
pub selection_method: SpectralSelectionMethod,
pub random_state: Option<u64>,
pub noise_variance: f64,
pub optimize_spectral_points: bool,
pub spectral_learning_rate: f64,
pub max_optimization_iterations: usize,
}Expand description
Sparse Spectrum Gaussian Process Regressor
Uses spectral approximation to scale Gaussian processes to large datasets by approximating the kernel using a sparse set of spectral points.
§Example
use sklears_gaussian_process::{SparseSpectrumGaussianProcessRegressor, kernels::RBF};
use sklears_core::prelude::*;
// SciRS2 Policy - Use scirs2-autograd for ndarray types and operations
let kernel = Box::new(RBF::new(1.0));
let model = SparseSpectrumGaussianProcessRegressor::new(kernel)
.num_spectral_points(50)
.spectral_density_threshold(1e-6);
let X = Array2::from_shape_vec((10, 2), (0..20).map(|x| x as f64).collect()).unwrap();
let y = Array1::from_vec((0..10).map(|x| (x as f64).sin()).collect());
let trained_model = model.fit(&X.view(), &y.view()).unwrap();
let predictions = trained_model.predict(&X.view()).unwrap();Fields§
§kernel: Box<dyn Kernel>Base kernel to approximate
num_spectral_points: usizeNumber of spectral points to use
spectral_density_threshold: f64Threshold for spectral density selection
selection_method: SpectralSelectionMethodMethod for selecting spectral points
random_state: Option<u64>Random state for reproducible results
noise_variance: f64Noise variance parameter
optimize_spectral_points: boolWhether to optimize spectral points during training
spectral_learning_rate: f64Learning rate for spectral point optimization
max_optimization_iterations: usizeMaximum iterations for optimization
Implementations§
Source§impl SparseSpectrumGaussianProcessRegressor
impl SparseSpectrumGaussianProcessRegressor
Sourcepub fn new(kernel: Box<dyn Kernel>) -> Self
pub fn new(kernel: Box<dyn Kernel>) -> Self
Create a new sparse spectrum Gaussian process regressor
Sourcepub fn num_spectral_points(self, num_points: usize) -> Self
pub fn num_spectral_points(self, num_points: usize) -> Self
Set the number of spectral points
Sourcepub fn spectral_density_threshold(self, threshold: f64) -> Self
pub fn spectral_density_threshold(self, threshold: f64) -> Self
Set the spectral density threshold
Sourcepub fn selection_method(self, method: SpectralSelectionMethod) -> Self
pub fn selection_method(self, method: SpectralSelectionMethod) -> Self
Set the spectral selection method
Sourcepub fn noise_variance(self, variance: f64) -> Self
pub fn noise_variance(self, variance: f64) -> Self
Set the noise variance
Sourcepub fn optimize_spectral_points(self, optimize: bool) -> Self
pub fn optimize_spectral_points(self, optimize: bool) -> Self
Set whether to optimize spectral points
Sourcepub fn random_state(self, seed: Option<u64>) -> Self
pub fn random_state(self, seed: Option<u64>) -> Self
Set random state for reproducible results
Sourcepub fn compute_approximation_info(
&self,
spectral_points: &Array2<f64>,
spectral_weights: &Array1<f64>,
) -> SklResult<SpectralApproximationInfo>
pub fn compute_approximation_info( &self, spectral_points: &Array2<f64>, spectral_weights: &Array1<f64>, ) -> SklResult<SpectralApproximationInfo>
Compute spectral approximation quality metrics
Trait Implementations§
Source§impl Clone for SparseSpectrumGaussianProcessRegressor
impl Clone for SparseSpectrumGaussianProcessRegressor
Source§fn clone(&self) -> SparseSpectrumGaussianProcessRegressor
fn clone(&self) -> SparseSpectrumGaussianProcessRegressor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Estimator for SparseSpectrumGaussianProcessRegressor
impl Estimator for SparseSpectrumGaussianProcessRegressor
Source§type Config = SparseSpectrumGaussianProcessRegressor
type Config = SparseSpectrumGaussianProcessRegressor
Source§type Error = SklearsError
type Error = SklearsError
Source§fn validate_config(&self) -> Result<(), SklearsError>
fn validate_config(&self) -> Result<(), SklearsError>
Source§fn check_compatibility(
&self,
n_samples: usize,
n_features: usize,
) -> Result<(), SklearsError>
fn check_compatibility( &self, n_samples: usize, n_features: usize, ) -> Result<(), SklearsError>
Source§fn metadata(&self) -> EstimatorMetadata
fn metadata(&self) -> EstimatorMetadata
Source§impl Fit<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, SparseSpectrumGprTrained> for SparseSpectrumGaussianProcessRegressor
impl Fit<ArrayBase<ViewRepr<&f64>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&f64>, Dim<[usize; 1]>>, SparseSpectrumGprTrained> for SparseSpectrumGaussianProcessRegressor
Source§type Fitted = SparseSpectrumGprTrained
type Fitted = SparseSpectrumGprTrained
Source§fn fit(
self,
X: &ArrayView2<'_, f64>,
y: &ArrayView1<'_, f64>,
) -> SklResult<SparseSpectrumGprTrained>
fn fit( self, X: &ArrayView2<'_, f64>, y: &ArrayView1<'_, f64>, ) -> SklResult<SparseSpectrumGprTrained>
Source§fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
Auto Trait Implementations§
impl Freeze for SparseSpectrumGaussianProcessRegressor
impl !RefUnwindSafe for SparseSpectrumGaussianProcessRegressor
impl Send for SparseSpectrumGaussianProcessRegressor
impl Sync for SparseSpectrumGaussianProcessRegressor
impl Unpin for SparseSpectrumGaussianProcessRegressor
impl !UnwindSafe for SparseSpectrumGaussianProcessRegressor
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
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 more