pub struct NMF<F> { /* private fields */ }Expand description
Non-negative Matrix Factorization configuration.
Holds hyperparameters for the NMF decomposition. Calling Fit::fit
computes the factorization and returns a FittedNMF that can
project new data via Transform::transform.
Implementations§
Source§impl<F: Float + Send + Sync + 'static> NMF<F>
impl<F: Float + Send + Sync + 'static> NMF<F>
Sourcepub fn new(n_components: usize) -> Self
pub fn new(n_components: usize) -> Self
Create a new NMF that extracts n_components components.
Defaults: max_iter=200, tol=1e-4, solver=MultiplicativeUpdate,
init=Random, no random seed.
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 iterations.
Sourcepub fn with_solver(self, solver: NMFSolver) -> Self
pub fn with_solver(self, solver: NMFSolver) -> Self
Set the solver algorithm.
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.
Sourcepub fn random_state(&self) -> Option<u64>
pub fn random_state(&self) -> Option<u64>
Return the configured random state, if any.
Trait Implementations§
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for NMF<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for NMF<F>
Source§fn fit(&self, x: &Array2<F>, _y: &()) -> Result<FittedNMF<F>, FerroError>
fn fit(&self, x: &Array2<F>, _y: &()) -> Result<FittedNMF<F>, FerroError>
Fit the NMF model by decomposing X ~ W * H.
§Errors
FerroError::InvalidParameterifn_componentsis zero or exceeds the minimum ofn_samplesandn_features.FerroError::InvalidParameterif any entry ofXis negative.FerroError::InsufficientSamplesif there are zero samples.FerroError::ConvergenceFailureif NNDSVD initialization fails.
Source§type Error = FerroError
type Error = FerroError
The error type returned by
fit.Source§impl<F: Float + Send + Sync + 'static> PipelineTransformer<F> for NMF<F>
impl<F: Float + Send + Sync + 'static> PipelineTransformer<F> for NMF<F>
Source§fn fit_pipeline(
&self,
x: &Array2<F>,
_y: &Array1<F>,
) -> Result<Box<dyn FittedPipelineTransformer<F>>, FerroError>
fn fit_pipeline( &self, x: &Array2<F>, _y: &Array1<F>, ) -> Result<Box<dyn FittedPipelineTransformer<F>>, FerroError>
Auto Trait Implementations§
impl<F> Freeze for NMF<F>
impl<F> RefUnwindSafe for NMF<F>where
F: RefUnwindSafe,
impl<F> Send for NMF<F>where
F: Send,
impl<F> Sync for NMF<F>where
F: Sync,
impl<F> Unpin for NMF<F>where
F: Unpin,
impl<F> UnsafeUnpin for NMF<F>
impl<F> UnwindSafe for NMF<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