pub struct GaussianNaiveBayes { /* private fields */ }Expand description
Online Gaussian Naive Bayes classifier.
Assumes features are conditionally independent given the class, and each feature follows a Gaussian distribution per class. Uses Welford’s algorithm for numerically stable variance updates.
§Examples
use rill_ml::models::GaussianNaiveBayes;
use rill_ml::OnlineBinaryClassifier;
let mut model = GaussianNaiveBayes::new(2, Default::default()).unwrap();
model.learn(&[1.0, 2.0], true).unwrap();
model.learn(&[-1.0, -2.0], false).unwrap();
let proba = model.predict_proba(&[0.5, 1.0]).unwrap();
assert!(proba > 0.0 && proba < 1.0);Implementations§
Trait Implementations§
Source§impl Clone for GaussianNaiveBayes
impl Clone for GaussianNaiveBayes
Source§fn clone(&self) -> GaussianNaiveBayes
fn clone(&self) -> GaussianNaiveBayes
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 GaussianNaiveBayes
impl Debug for GaussianNaiveBayes
Source§impl OnlineBinaryClassifier for GaussianNaiveBayes
impl OnlineBinaryClassifier for GaussianNaiveBayes
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 GaussianNaiveBayes
impl RefUnwindSafe for GaussianNaiveBayes
impl Send for GaussianNaiveBayes
impl Sync for GaussianNaiveBayes
impl Unpin for GaussianNaiveBayes
impl UnsafeUnpin for GaussianNaiveBayes
impl UnwindSafe for GaussianNaiveBayes
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