pub struct NMF<State = Untrained> {
pub n_components: usize,
pub init: NMFInit,
pub solver: NMFSolver,
pub regularization: NMFRegularization,
pub alpha_w: f64,
pub alpha_h: f64,
pub l1_ratio: f64,
pub max_iter: usize,
pub tol: f64,
pub random_state: Option<u64>,
/* private fields */
}Expand description
Non-negative Matrix Factorization transformer
Fields§
§n_components: usizeNumber of components/topics
init: NMFInitInitialization method
solver: NMFSolverSolver algorithm
regularization: NMFRegularizationRegularization type
alpha_w: f64L1 regularization strength
alpha_h: f64L2 regularization strength
l1_ratio: f64L1 ratio for elastic net regularization
max_iter: usizeMaximum number of iterations
tol: f64Tolerance for convergence
random_state: Option<u64>Random state for reproducibility
Implementations§
Source§impl NMF<Untrained>
impl NMF<Untrained>
Sourcepub fn regularization(
self,
regularization: NMFRegularization,
alpha: f64,
) -> Self
pub fn regularization( self, regularization: NMFRegularization, alpha: f64, ) -> Self
Set regularization parameters
Sourcepub fn random_state(self, random_state: u64) -> Self
pub fn random_state(self, random_state: u64) -> Self
Set random state
Source§impl NMF<TrainedNMF>
impl NMF<TrainedNMF>
Sourcepub fn components(&self) -> Array2<f64>
pub fn components(&self) -> Array2<f64>
Get the components matrix (W)
Sourcepub fn reconstruction_err(&self) -> f64
pub fn reconstruction_err(&self) -> f64
Get the reconstruction error
Trait Implementations§
Source§impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ()> for NMF<Untrained>
impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ()> for NMF<Untrained>
Source§type Fitted = NMF<TrainedNMF>
type Fitted = NMF<TrainedNMF>
The fitted model type
Source§fn fit(self, x: &Array2<f64>, _y: &()) -> Result<Self::Fitted>
fn fit(self, x: &Array2<f64>, _y: &()) -> Result<Self::Fitted>
Fit the model to the provided data with validation
Source§fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
Fit with custom validation and early stopping
Auto Trait Implementations§
impl<State> Freeze for NMF<State>where
State: Freeze,
impl<State> RefUnwindSafe for NMF<State>where
State: RefUnwindSafe,
impl<State> Send for NMF<State>where
State: Send,
impl<State> Sync for NMF<State>where
State: Sync,
impl<State> Unpin for NMF<State>where
State: Unpin,
impl<State> UnsafeUnpin for NMF<State>where
State: UnsafeUnpin,
impl<State> UnwindSafe for NMF<State>where
State: 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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