pub struct FittedKernelPCA<K: Kernel> { /* private fields */ }Expand description
A fitted Kernel-PCA model. Stores everything required to project
new data into the learned principal subspace: the kernel, the
scaled eigenvectors alpha = v / sqrt(lambda), the raw
eigenvalues, the training points, and the centering statistics.
Implementations§
Source§impl<K: Kernel> FittedKernelPCA<K>
impl<K: Kernel> FittedKernelPCA<K>
Sourcepub fn n_components(&self) -> usize
pub fn n_components(&self) -> usize
Number of components kept at fit time.
Sourcepub fn feature_dim(&self) -> usize
pub fn feature_dim(&self) -> usize
Feature dimension expected by Self::transform.
Sourcepub fn eigenvalues(&self) -> &Array1<f64>
pub fn eigenvalues(&self) -> &Array1<f64>
Eigenvalues of the centered Gram matrix corresponding to the retained components, sorted in descending order.
Sourcepub fn alphas(&self) -> &Array2<f64>
pub fn alphas(&self) -> &Array2<f64>
Scaled eigenvectors alpha_k = v_k / sqrt(lambda_k) as an
(n_training, n_components) matrix.
Sourcepub fn training_data(&self) -> &[Vec<f64>]
pub fn training_data(&self) -> &[Vec<f64>]
Borrowed view of the training data retained for projection.
Sourcepub fn centering_stats(&self) -> &KernelCenteringStats
pub fn centering_stats(&self) -> &KernelCenteringStats
Centering statistics captured at fit time.
Sourcepub fn explained_variance_ratio(&self) -> Array1<f64>
pub fn explained_variance_ratio(&self) -> Array1<f64>
Fraction of centered-Gram variance explained by each retained
component. The i-th entry is
eigenvalues[i] / sum_j eigenvalues[j]. Returns a zero-length
array if the kept eigenvalues are (numerically) zero.
Sourcepub fn transform(&self, points: &[Vec<f64>]) -> KernelPcaResult<Array2<f64>>
pub fn transform(&self, points: &[Vec<f64>]) -> KernelPcaResult<Array2<f64>>
Project new points into the learned principal subspace.
The returned matrix has shape (points.len(), n_components)
and row i is the embedding of points[i].
§Errors
KernelPcaError::DimensionMismatchif any row ofpointshas a different feature dimension than the training data.KernelPcaError::InvalidInputifpointsis empty.
Trait Implementations§
Auto Trait Implementations§
impl<K> Freeze for FittedKernelPCA<K>
impl<K> !RefUnwindSafe for FittedKernelPCA<K>
impl<K> Send for FittedKernelPCA<K>
impl<K> Sync for FittedKernelPCA<K>
impl<K> Unpin for FittedKernelPCA<K>where
K: Unpin,
impl<K> UnsafeUnpin for FittedKernelPCA<K>
impl<K> !UnwindSafe for FittedKernelPCA<K>
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> 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