pub struct NmfTopicModel { /* private fields */ }Expand description
NMF-based topic model.
Factorizes a term-document matrix V ~ W * H where:
- W (n_docs x n_topics): document-topic weights
- H (n_topics x n_terms): topic-term weights
Uses multiplicative update rules (Lee & Seung, 2001).
Implementations§
Source§impl NmfTopicModel
impl NmfTopicModel
Sourcepub fn fit(&mut self, matrix: &Array2<f64>, vocabulary: &[String]) -> Result<()>
pub fn fit(&mut self, matrix: &Array2<f64>, vocabulary: &[String]) -> Result<()>
Fit NMF on a non-negative document-term matrix.
matrix is (n_docs, n_terms), vocabulary maps index -> word.
Sourcepub fn doc_topic_matrix(&self) -> Result<&Array2<f64>>
pub fn doc_topic_matrix(&self) -> Result<&Array2<f64>>
Get the document-topic matrix W.
Sourcepub fn topic_term_matrix(&self) -> Result<&Array2<f64>>
pub fn topic_term_matrix(&self) -> Result<&Array2<f64>>
Get the topic-term matrix H.
Sourcepub fn top_words(&self, n_words: usize) -> Result<Vec<Vec<(String, f64)>>>
pub fn top_words(&self, n_words: usize) -> Result<Vec<Vec<(String, f64)>>>
Get top words for each topic.
Sourcepub fn error_history(&self) -> &[f64]
pub fn error_history(&self) -> &[f64]
Get the reconstruction error history.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NmfTopicModel
impl RefUnwindSafe for NmfTopicModel
impl Send for NmfTopicModel
impl Sync for NmfTopicModel
impl Unpin for NmfTopicModel
impl UnsafeUnpin for NmfTopicModel
impl UnwindSafe for NmfTopicModel
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> 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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.