pub struct FittedSparsePCA<F> { /* private fields */ }Expand description
A fitted Sparse PCA model holding the learned components.
Created by calling Fit::fit on a SparsePCA. Implements
Transform<Array2<F>> to project new data onto the sparse components.
Implementations§
Trait Implementations§
Source§impl<F: Clone> Clone for FittedSparsePCA<F>
impl<F: Clone> Clone for FittedSparsePCA<F>
Source§fn clone(&self) -> FittedSparsePCA<F>
fn clone(&self) -> FittedSparsePCA<F>
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<F: Debug> Debug for FittedSparsePCA<F>
impl<F: Debug> Debug for FittedSparsePCA<F>
Source§impl<F: Float + Send + Sync + 'static> Transform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for FittedSparsePCA<F>
impl<F: Float + Send + Sync + 'static> Transform<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>> for FittedSparsePCA<F>
Source§fn transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
fn transform(&self, x: &Array2<F>) -> Result<Array2<F>, FerroError>
Least-squares projection of the data onto the sparse components.
Because the sparse components_ are not orthonormal, a plain linear
projection is incorrect (see scikit-learn _BaseSparsePCA.transform,
_sparse_pca.py:93-123). Instead this computes the ridge-regularised
least-squares fit
U = ridge_regression(components_.T, X_centered.T, ridge_alpha), i.e.
U = (X - mean) · Cᵀ · (C·Cᵀ + ridge_alpha·I)⁻¹ with C = components_
and ridge_alpha = 0.01 (sklearn default).
§Errors
- Returns
FerroError::ShapeMismatchif the number of columns does not match the number of features seen during fitting. - Returns
FerroError::NumericalInstabilityif the ridge systemC·Cᵀ + ridge_alpha·Iis singular (should not occur forridge_alpha > 0).
Source§type Error = FerroError
type Error = FerroError
The error type returned by
transform.Auto Trait Implementations§
impl<F> Freeze for FittedSparsePCA<F>
impl<F> RefUnwindSafe for FittedSparsePCA<F>where
F: RefUnwindSafe,
impl<F> Send for FittedSparsePCA<F>where
F: Send,
impl<F> Sync for FittedSparsePCA<F>where
F: Sync,
impl<F> Unpin for FittedSparsePCA<F>
impl<F> UnsafeUnpin for FittedSparsePCA<F>
impl<F> UnwindSafe for FittedSparsePCA<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
Mutably borrows from an owned value. Read more
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,
impl<T, U> Imply<T> for U
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>
Converts
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>
Converts
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