Struct rusty_machine::learning::naive_bayes::NaiveBayes
source · [−]pub struct NaiveBayes<T: Distribution> { /* private fields */ }
Expand description
The Naive Bayes model.
Implementations
sourceimpl<T: Distribution> NaiveBayes<T>
impl<T: Distribution> NaiveBayes<T>
sourcepub fn new() -> NaiveBayes<T>
pub fn new() -> NaiveBayes<T>
Create a new NaiveBayes model from a given distribution.
Examples
use rusty_machine::learning::naive_bayes::{NaiveBayes, Gaussian};
// Create a new Gaussian Naive Bayes model.
let _ = NaiveBayes::<Gaussian>::new();
sourcepub fn cluster_count(&self) -> Option<&usize>
pub fn cluster_count(&self) -> Option<&usize>
Get the cluster count for this model.
Returns an option which is None
until the model has been trained.
sourcepub fn class_prior(&self) -> Option<&Vec<f64>>
pub fn class_prior(&self) -> Option<&Vec<f64>>
Get the class prior distribution for this model.
Returns an option which is None
until the model has been trained.
sourceimpl<T: Distribution> NaiveBayes<T>
impl<T: Distribution> NaiveBayes<T>
sourcepub fn get_log_probs(&self, inputs: &Matrix<f64>) -> LearningResult<Matrix<f64>>
pub fn get_log_probs(&self, inputs: &Matrix<f64>) -> LearningResult<Matrix<f64>>
Get the log-probabilities per class for each input.
Trait Implementations
sourceimpl<T: Debug + Distribution> Debug for NaiveBayes<T>
impl<T: Debug + Distribution> Debug for NaiveBayes<T>
sourceimpl<T: Default + Distribution> Default for NaiveBayes<T>
impl<T: Default + Distribution> Default for NaiveBayes<T>
sourcefn default() -> NaiveBayes<T>
fn default() -> NaiveBayes<T>
Returns the “default value” for a type. Read more
sourceimpl<T: Distribution> SupModel<Matrix<f64>, Matrix<f64>> for NaiveBayes<T>
impl<T: Distribution> SupModel<Matrix<f64>, Matrix<f64>> for NaiveBayes<T>
Train and predict from the Naive Bayes model.
The input matrix must be rows made up of features. The target matrix should have indicator vectors in each row specifying the input class. e.g. [[1,0,0],[0,0,1]] shows class 1 first, then class 3.
sourcefn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Matrix<f64>
) -> LearningResult<()>
fn train(
&mut self,
inputs: &Matrix<f64>,
targets: &Matrix<f64>
) -> LearningResult<()>
Train the model using inputs and targets.
sourcefn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Matrix<f64>>
fn predict(&self, inputs: &Matrix<f64>) -> LearningResult<Matrix<f64>>
Predict output from inputs.
Auto Trait Implementations
impl<T> RefUnwindSafe for NaiveBayes<T>where
T: RefUnwindSafe,
impl<T> Send for NaiveBayes<T>where
T: Send,
impl<T> Sync for NaiveBayes<T>where
T: Sync,
impl<T> Unpin for NaiveBayes<T>where
T: Unpin,
impl<T> UnwindSafe for NaiveBayes<T>where
T: UnwindSafe,
Blanket Implementations
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstablefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more