pub struct SparsePCA<F> { /* private fields */ }Expand description
Sparse PCA configuration.
Holds hyperparameters for the Sparse PCA decomposition. Calling
Fit::fit performs the iterative elastic-net / coordinate-descent
procedure and returns a FittedSparsePCA that can project new data.
Implementations§
Source§impl<F: Float + Send + Sync + 'static> SparsePCA<F>
impl<F: Float + Send + Sync + 'static> SparsePCA<F>
Sourcepub fn new(n_components: usize) -> Self
pub fn new(n_components: usize) -> Self
Create a new SparsePCA that extracts n_components sparse components.
Defaults: alpha = 1.0, max_iter = 1000, tol = 1e-8,
random_state = None.
Sourcepub fn with_alpha(self, alpha: f64) -> Self
pub fn with_alpha(self, alpha: f64) -> Self
Set the sparsity penalty weight (L1 regularisation on codes).
Sourcepub fn with_max_iter(self, max_iter: usize) -> Self
pub fn with_max_iter(self, max_iter: usize) -> Self
Set the maximum number of outer iterations.
Sourcepub fn with_random_state(self, seed: u64) -> Self
pub fn with_random_state(self, seed: u64) -> Self
Set the random seed for reproducible results.
Sourcepub fn n_components(&self) -> usize
pub fn n_components(&self) -> usize
Return the configured number of components.
Trait Implementations§
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for SparsePCA<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for SparsePCA<F>
Source§fn fit(&self, x: &Array2<F>, _y: &()) -> Result<FittedSparsePCA<F>, FerroError>
fn fit(&self, x: &Array2<F>, _y: &()) -> Result<FittedSparsePCA<F>, FerroError>
Fit Sparse PCA by alternating sparse coding and dictionary update.
§Errors
FerroError::InvalidParameterifn_componentsis zero or exceeds the number of features.FerroError::InsufficientSamplesif there are fewer than 2 samples.
Source§type Fitted = FittedSparsePCA<F>
type Fitted = FittedSparsePCA<F>
The fitted model type returned by
fit.Source§type Error = FerroError
type Error = FerroError
The error type returned by
fit.Auto Trait Implementations§
impl<F> Freeze for SparsePCA<F>
impl<F> RefUnwindSafe for SparsePCA<F>where
F: RefUnwindSafe,
impl<F> Send for SparsePCA<F>where
F: Send,
impl<F> Sync for SparsePCA<F>where
F: Sync,
impl<F> Unpin for SparsePCA<F>where
F: Unpin,
impl<F> UnsafeUnpin for SparsePCA<F>
impl<F> UnwindSafe for SparsePCA<F>where
F: 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
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,
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