pub struct CountVectorizer { /* private fields */ }Expand description
Complete Count Vectorizer implementation for text feature extraction
Converts a collection of text documents to a matrix of token counts. Supports n-grams, stop word filtering, and various preprocessing options.
Implementations§
Source§impl CountVectorizer
impl CountVectorizer
Sourcepub fn max_features(self, max_features: Option<usize>) -> Self
pub fn max_features(self, max_features: Option<usize>) -> Self
Set maximum number of features to select
Sourcepub fn min_df(self, min_df: usize) -> Self
pub fn min_df(self, min_df: usize) -> Self
Set minimum document frequency for feature inclusion
Sourcepub fn ngram_range(self, ngram_range: (usize, usize)) -> Self
pub fn ngram_range(self, ngram_range: (usize, usize)) -> Self
Set n-gram range (min_n, max_n)
Sourcepub fn stop_words(self, stop_words: Option<Vec<String>>) -> Self
pub fn stop_words(self, stop_words: Option<Vec<String>>) -> Self
Set stop words to filter out
Sourcepub fn fit_instance_method(&mut self, documents: &[String]) -> SklResult<()>
pub fn fit_instance_method(&mut self, documents: &[String]) -> SklResult<()>
Fit the vectorizer to a collection of documents
Sourcepub fn transform(&self, documents: &[String]) -> SklResult<Array2<Float>>
pub fn transform(&self, documents: &[String]) -> SklResult<Array2<Float>>
Transform documents to feature vectors
Sourcepub fn fit_transform(
&mut self,
documents: &[String],
) -> SklResult<Array2<Float>>
pub fn fit_transform( &mut self, documents: &[String], ) -> SklResult<Array2<Float>>
Fit and transform in one step
Sourcepub fn get_feature_names(&self) -> &[String]
pub fn get_feature_names(&self) -> &[String]
Get feature names
Trait Implementations§
Source§impl Clone for CountVectorizer
impl Clone for CountVectorizer
Source§impl Debug for CountVectorizer
impl Debug for CountVectorizer
Source§impl Default for CountVectorizer
impl Default for CountVectorizer
Source§impl Fit<Vec<String>, ()> for CountVectorizer
impl Fit<Vec<String>, ()> for CountVectorizer
Source§type Fitted = FittedCountVectorizer
type Fitted = FittedCountVectorizer
The fitted model type
Source§fn fit(self, x: &Vec<String>, _y: &()) -> SklResult<Self::Fitted>
fn fit(self, x: &Vec<String>, _y: &()) -> SklResult<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 Freeze for CountVectorizer
impl RefUnwindSafe for CountVectorizer
impl Send for CountVectorizer
impl Sync for CountVectorizer
impl Unpin for CountVectorizer
impl UnsafeUnpin for CountVectorizer
impl UnwindSafe for CountVectorizer
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