pub struct BernoulliNaiveBayes { /* private fields */ }Expand description
Online Bernoulli Naive Bayes classifier.
Designed for binary features (0 or 1). Uses Laplace smoothing for probability estimation.
§Examples
use rill_ml::models::BernoulliNaiveBayes;
use rill_ml::OnlineBinaryClassifier;
let mut model = BernoulliNaiveBayes::new(3, Default::default()).unwrap();
model.learn(&[1.0, 0.0, 1.0], true).unwrap();
model.learn(&[0.0, 1.0, 0.0], false).unwrap();
let proba = model.predict_proba(&[1.0, 0.0, 1.0]).unwrap();
assert!(proba > 0.5);Implementations§
Trait Implementations§
Source§impl Clone for BernoulliNaiveBayes
impl Clone for BernoulliNaiveBayes
Source§fn clone(&self) -> BernoulliNaiveBayes
fn clone(&self) -> BernoulliNaiveBayes
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 BernoulliNaiveBayes
impl Debug for BernoulliNaiveBayes
Source§impl OnlineBinaryClassifier for BernoulliNaiveBayes
impl OnlineBinaryClassifier for BernoulliNaiveBayes
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 BernoulliNaiveBayes
impl RefUnwindSafe for BernoulliNaiveBayes
impl Send for BernoulliNaiveBayes
impl Sync for BernoulliNaiveBayes
impl Unpin for BernoulliNaiveBayes
impl UnsafeUnpin for BernoulliNaiveBayes
impl UnwindSafe for BernoulliNaiveBayes
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