pub struct TopicModel {
pub model_type: TopicModelType,
pub num_topics: usize,
pub num_terms: usize,
pub num_documents: usize,
pub max_iterations: usize,
pub tolerance: f64,
pub random_state: Option<u64>,
pub topic_term_matrix: Option<Array2<f64>>,
pub document_topic_matrix: Option<Array2<f64>>,
pub vocabulary: HashMap<String, usize>,
pub topic_words: Vec<Vec<(String, f64)>>,
pub is_trained: bool,
}Expand description
Topic Model for dimensionality reduction and feature extraction
Fields§
§model_type: TopicModelType§num_topics: usize§num_terms: usize§num_documents: usize§max_iterations: usize§tolerance: f64§random_state: Option<u64>§topic_term_matrix: Option<Array2<f64>>§document_topic_matrix: Option<Array2<f64>>§vocabulary: HashMap<String, usize>§topic_words: Vec<Vec<(String, f64)>>§is_trained: boolImplementations§
Source§impl TopicModel
impl TopicModel
Sourcepub fn new(
model_type: TopicModelType,
num_topics: usize,
max_iterations: usize,
tolerance: f64,
random_state: Option<u64>,
) -> Result<Self, TopicModelError>
pub fn new( model_type: TopicModelType, num_topics: usize, max_iterations: usize, tolerance: f64, random_state: Option<u64>, ) -> Result<Self, TopicModelError>
Create a new topic model
Sourcepub fn fit(
&mut self,
doc_term_matrix: &Array2<f64>,
) -> Result<(), TopicModelError>
pub fn fit( &mut self, doc_term_matrix: &Array2<f64>, ) -> Result<(), TopicModelError>
Fit the topic model on document-term matrix
Sourcepub fn transform(
&self,
doc_term_matrix: &Array2<f64>,
) -> Result<Array2<f64>, TopicModelError>
pub fn transform( &self, doc_term_matrix: &Array2<f64>, ) -> Result<Array2<f64>, TopicModelError>
Transform documents to topic space
Sourcepub fn get_topic_words(
&self,
num_words: usize,
) -> Result<Vec<Vec<(usize, f64)>>, TopicModelError>
pub fn get_topic_words( &self, num_words: usize, ) -> Result<Vec<Vec<(usize, f64)>>, TopicModelError>
Get top words for each topic
Sourcepub fn get_document_topics(
&self,
doc_idx: usize,
) -> Result<Array1<f64>, TopicModelError>
pub fn get_document_topics( &self, doc_idx: usize, ) -> Result<Array1<f64>, TopicModelError>
Get topic distribution for a document
Trait Implementations§
Source§impl Clone for TopicModel
impl Clone for TopicModel
Source§fn clone(&self) -> TopicModel
fn clone(&self) -> TopicModel
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 moreAuto Trait Implementations§
impl Freeze for TopicModel
impl RefUnwindSafe for TopicModel
impl Send for TopicModel
impl Sync for TopicModel
impl Unpin for TopicModel
impl UnsafeUnpin for TopicModel
impl UnwindSafe for TopicModel
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