pub struct FittedPCA<F> { /* private fields */ }Expand description
A fitted PCA model holding the learned principal components and statistics.
Created by calling Fit::fit on a PCA. Implements
Transform<Array2<F>> to project new data, and provides
inverse_transform to reconstruct
approximate original data.
Implementations§
Source§impl<F: Float + Send + Sync + 'static> FittedPCA<F>
impl<F: Float + Send + Sync + 'static> FittedPCA<F>
Sourcepub fn components(&self) -> &Array2<F>
pub fn components(&self) -> &Array2<F>
Principal components, shape (n_components, n_features).
Sourcepub fn explained_variance(&self) -> &Array1<F>
pub fn explained_variance(&self) -> &Array1<F>
Explained variance per component (eigenvalues).
Sourcepub fn explained_variance_ratio(&self) -> &Array1<F>
pub fn explained_variance_ratio(&self) -> &Array1<F>
Explained variance ratio per component.
Sourcepub fn singular_values(&self) -> &Array1<F>
pub fn singular_values(&self) -> &Array1<F>
Singular values corresponding to each component.
Sourcepub fn inverse_transform(
&self,
x_reduced: &Array2<F>,
) -> Result<Array2<F>, FerroError>
pub fn inverse_transform( &self, x_reduced: &Array2<F>, ) -> Result<Array2<F>, FerroError>
Reconstruct approximate original data from the reduced representation.
Computes X_approx = X_reduced @ components + mean.
§Errors
Returns FerroError::ShapeMismatch if the number of columns in
x_reduced does not equal n_components.
Trait Implementations§
Source§impl<F: Float + Send + Sync + 'static> FittedPipelineTransformer<F> for FittedPCA<F>
impl<F: Float + Send + Sync + 'static> FittedPipelineTransformer<F> for FittedPCA<F>
Source§fn transform_pipeline(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
fn transform_pipeline(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
Source§impl<F: Float + Send + Sync + 'static> Transform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for FittedPCA<F>
impl<F: Float + Send + Sync + 'static> Transform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for FittedPCA<F>
Source§fn transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
fn transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
Project data onto the principal components: (X - mean) @ components^T.
§Errors
Returns FerroError::ShapeMismatch if the number of columns does not
match the number of features seen during fitting.
Source§type Error = FerroError
type Error = FerroError
transform.Auto Trait Implementations§
impl<F> Freeze for FittedPCA<F>
impl<F> RefUnwindSafe for FittedPCA<F>where
F: RefUnwindSafe,
impl<F> Send for FittedPCA<F>where
F: Send,
impl<F> Sync for FittedPCA<F>where
F: Sync,
impl<F> Unpin for FittedPCA<F>
impl<F> UnsafeUnpin for FittedPCA<F>
impl<F> UnwindSafe for FittedPCA<F>where
F: RefUnwindSafe,
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> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
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