pub struct MultinomialNaiveBayes { /* private fields */ }Expand description
Online Multinomial Naive Bayes classifier.
Designed for count features (non-negative values). Uses Laplace smoothing. Commonly used for text classification with word counts.
§Examples
use rill_ml::models::MultinomialNaiveBayes;
use rill_ml::OnlineBinaryClassifier;
let mut model = MultinomialNaiveBayes::new(3, Default::default()).unwrap();
model.learn(&[2.0, 1.0, 0.0], true).unwrap();
model.learn(&[0.0, 1.0, 3.0], false).unwrap();
let proba = model.predict_proba(&[1.0, 1.0, 0.0]).unwrap();
assert!(proba > 0.0 && proba < 1.0);Implementations§
Trait Implementations§
Source§impl Clone for MultinomialNaiveBayes
impl Clone for MultinomialNaiveBayes
Source§fn clone(&self) -> MultinomialNaiveBayes
fn clone(&self) -> MultinomialNaiveBayes
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 Debug for MultinomialNaiveBayes
impl Debug for MultinomialNaiveBayes
Source§impl OnlineBinaryClassifier for MultinomialNaiveBayes
impl OnlineBinaryClassifier for MultinomialNaiveBayes
Source§fn feature_count(&self) -> usize
fn feature_count(&self) -> usize
The number of features the model expects.
Source§fn samples_seen(&self) -> u64
fn samples_seen(&self) -> u64
How many training samples the model has seen so far.
Source§fn predict_proba(&self, features: &[f64]) -> Result<f64, RillError>
fn predict_proba(&self, features: &[f64]) -> Result<f64, RillError>
Predict the probability of the positive class.
Auto Trait Implementations§
impl Freeze for MultinomialNaiveBayes
impl RefUnwindSafe for MultinomialNaiveBayes
impl Send for MultinomialNaiveBayes
impl Sync for MultinomialNaiveBayes
impl Unpin for MultinomialNaiveBayes
impl UnsafeUnpin for MultinomialNaiveBayes
impl UnwindSafe for MultinomialNaiveBayes
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