#[non_exhaustive]pub struct MultinomialNB { /* private fields */ }Expand description
Multinomial Naive Bayes — for count/frequency features.
Models each class as a multinomial distribution over features. Well-suited for document classification with term frequencies.
Uses Laplace smoothing (additive smoothing) to handle zero counts.
Implementations§
Source§impl MultinomialNB
impl MultinomialNB
Sourcepub fn class_weight(self, cw: ClassWeight) -> Self
pub fn class_weight(self, cw: ClassWeight) -> Self
Set class weighting strategy for imbalanced datasets.
Sourcepub fn fit(&mut self, data: &Dataset) -> Result<()>
pub fn fit(&mut self, data: &Dataset) -> Result<()>
Train the model on a dataset.
Features should be non-negative counts or frequencies.
Sourcepub fn fit_sparse(&mut self, features: &CscMatrix, target: &[f64]) -> Result<()>
pub fn fit_sparse(&mut self, features: &CscMatrix, target: &[f64]) -> Result<()>
Fit on sparse features (CSC format) — perfect for TF-IDF.
Sums non-zero entries per class per feature for count-based likelihood.
Sourcepub fn predict_sparse(&self, features: &CsrMatrix) -> Result<Vec<f64>>
pub fn predict_sparse(&self, features: &CsrMatrix) -> Result<Vec<f64>>
Predict from sparse features (CSR format).
Trait Implementations§
Source§impl CalibrableClassifier for MultinomialNB
impl CalibrableClassifier for MultinomialNB
Source§impl Clone for MultinomialNB
impl Clone for MultinomialNB
Source§fn clone(&self) -> MultinomialNB
fn clone(&self) -> MultinomialNB
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 moreSource§impl Default for MultinomialNB
impl Default for MultinomialNB
Source§impl PipelineModel for MultinomialNB
impl PipelineModel for MultinomialNB
Auto Trait Implementations§
impl Freeze for MultinomialNB
impl RefUnwindSafe for MultinomialNB
impl Send for MultinomialNB
impl Sync for MultinomialNB
impl Unpin for MultinomialNB
impl UnsafeUnpin for MultinomialNB
impl UnwindSafe for MultinomialNB
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> 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