pub struct KernelPCA<K: Kernel> { /* private fields */ }Expand description
Kernel-PCA estimator generic over any kernel that implements the
crate’s Kernel trait. Typical ones are
crate::RbfKernel, crate::LinearKernel, and
crate::PolynomialKernel, but crate::SymbolicKernel (built
with crate::KernelBuilder) also slots in.
KernelPCA is stateless — the “fitted model” is
FittedKernelPCA, returned by KernelPCA::fit or
KernelPCA::fit_transform.
Implementations§
Source§impl<K: Kernel> KernelPCA<K>
impl<K: Kernel> KernelPCA<K>
Sourcepub fn new(kernel: K, config: KernelPcaConfig) -> KernelPcaResult<Self>
pub fn new(kernel: K, config: KernelPcaConfig) -> KernelPcaResult<Self>
Build a new Kernel-PCA estimator from a kernel and a config.
§Errors
KernelPcaError::InvalidInputwhen the config requestsn_components == 0.
Sourcepub fn config(&self) -> &KernelPcaConfig
pub fn config(&self) -> &KernelPcaConfig
Access the configuration.
Source§impl<K: Kernel + Clone + 'static> KernelPCA<K>
impl<K: Kernel + Clone + 'static> KernelPCA<K>
Sourcepub fn build(kernel: K, config: KernelPcaConfig) -> KernelPcaResult<Self>
pub fn build(kernel: K, config: KernelPcaConfig) -> KernelPcaResult<Self>
Preferred constructor when the kernel is Clone + 'static —
identical signature to KernelPCA::new but re-exposed here so
that auto-derefs pick this up for the common case.
Sourcepub fn fit(&self, training: &[Vec<f64>]) -> KernelPcaResult<FittedKernelPCA<K>>
pub fn fit(&self, training: &[Vec<f64>]) -> KernelPcaResult<FittedKernelPCA<K>>
Fit the model on training — compute the Gram matrix, double
center it, eigendecompose, and cache the top-n_components
components for later projection.
§Errors
KernelPcaError::InvalidInputfor empty or ragged training sets.KernelPcaError::EigendecompositionFailedif the underlying solver fails.KernelPcaError::InsufficientComponentsif the kernel matrix does not have enough positive eigenvalues.
Sourcepub fn fit_transform(
&self,
training: &[Vec<f64>],
) -> KernelPcaResult<(FittedKernelPCA<K>, Array2<f64>)>
pub fn fit_transform( &self, training: &[Vec<f64>], ) -> KernelPcaResult<(FittedKernelPCA<K>, Array2<f64>)>
Convenience: fit on training and immediately project those
same points.
Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for KernelPCA<K>where
K: Freeze,
impl<K> RefUnwindSafe for KernelPCA<K>where
K: RefUnwindSafe,
impl<K> Send for KernelPCA<K>
impl<K> Sync for KernelPCA<K>
impl<K> Unpin for KernelPCA<K>where
K: Unpin,
impl<K> UnsafeUnpin for KernelPCA<K>where
K: UnsafeUnpin,
impl<K> UnwindSafe for KernelPCA<K>where
K: UnwindSafe,
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