Struct smartcore::naive_bayes::bernoulli::BernoulliNB
source · pub struct BernoulliNB<TX: Number + PartialOrd, TY: Number + Ord + Unsigned, X: Array2<TX>, Y: Array1<TY>> { /* private fields */ }
Expand description
BernoulliNB implements the naive Bayes algorithm for data that follows the Bernoulli distribution.
Implementations§
source§impl<TX: Number + PartialOrd, TY: Number + Ord + Unsigned, X: Array2<TX>, Y: Array1<TY>> BernoulliNB<TX, TY, X, Y>
impl<TX: Number + PartialOrd, TY: Number + Ord + Unsigned, X: Array2<TX>, Y: Array1<TY>> BernoulliNB<TX, TY, X, Y>
sourcepub fn fit(
x: &X,
y: &Y,
parameters: BernoulliNBParameters<TX>
) -> Result<Self, Failed>
pub fn fit( x: &X, y: &Y, parameters: BernoulliNBParameters<TX> ) -> Result<Self, Failed>
Fits BernoulliNB with given data
x
- training data of size NxM where N is the number of samples and M is the number of features.y
- vector with target values (classes) of length N.parameters
- additional parameters like class priors, alpha for smoothing and binarizing threshold.
sourcepub fn predict(&self, x: &X) -> Result<Y, Failed>
pub fn predict(&self, x: &X) -> Result<Y, Failed>
Estimates the class labels for the provided data.
x
- data of shape NxM where N is number of data points to estimate and M is number of features. Returns a vector of size N with class estimates.
sourcepub fn classes(&self) -> &Vec<TY>
pub fn classes(&self) -> &Vec<TY>
Class labels known to the classifier. Returns a vector of size n_classes.
sourcepub fn class_count(&self) -> &Vec<usize>
pub fn class_count(&self) -> &Vec<usize>
Number of training samples observed in each class. Returns a vector of size n_classes.
sourcepub fn n_features(&self) -> usize
pub fn n_features(&self) -> usize
Number of features of each sample
sourcepub fn feature_count(&self) -> &Vec<Vec<usize>>
pub fn feature_count(&self) -> &Vec<Vec<usize>>
Number of samples encountered for each (class, feature) Returns a 2d vector of shape (n_classes, n_features)
sourcepub fn feature_log_prob(&self) -> &Vec<Vec<f64>>
pub fn feature_log_prob(&self) -> &Vec<Vec<f64>>
Empirical log probability of features given a class
Trait Implementations§
source§impl<TX: Debug + Number + PartialOrd, TY: Debug + Number + Ord + Unsigned, X: Debug + Array2<TX>, Y: Debug + Array1<TY>> Debug for BernoulliNB<TX, TY, X, Y>
impl<TX: Debug + Number + PartialOrd, TY: Debug + Number + Ord + Unsigned, X: Debug + Array2<TX>, Y: Debug + Array1<TY>> Debug for BernoulliNB<TX, TY, X, Y>
source§impl<TX: Number + PartialOrd, TY: Number + Ord + Unsigned, X: Array2<TX>, Y: Array1<TY>> Display for BernoulliNB<TX, TY, X, Y>
impl<TX: Number + PartialOrd, TY: Number + Ord + Unsigned, X: Array2<TX>, Y: Array1<TY>> Display for BernoulliNB<TX, TY, X, Y>
source§impl<TX: PartialEq + Number + PartialOrd, TY: PartialEq + Number + Ord + Unsigned, X: PartialEq + Array2<TX>, Y: PartialEq + Array1<TY>> PartialEq<BernoulliNB<TX, TY, X, Y>> for BernoulliNB<TX, TY, X, Y>
impl<TX: PartialEq + Number + PartialOrd, TY: PartialEq + Number + Ord + Unsigned, X: PartialEq + Array2<TX>, Y: PartialEq + Array1<TY>> PartialEq<BernoulliNB<TX, TY, X, Y>> for BernoulliNB<TX, TY, X, Y>
source§fn eq(&self, other: &BernoulliNB<TX, TY, X, Y>) -> bool
fn eq(&self, other: &BernoulliNB<TX, TY, X, Y>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<TX: Number + PartialOrd, TY: Number + Ord + Unsigned, X: Array2<TX>, Y: Array1<TY>> Predictor<X, Y> for BernoulliNB<TX, TY, X, Y>
impl<TX: Number + PartialOrd, TY: Number + Ord + Unsigned, X: Array2<TX>, Y: Array1<TY>> Predictor<X, Y> for BernoulliNB<TX, TY, X, Y>
source§impl<TX: Number + PartialOrd, TY: Number + Ord + Unsigned, X: Array2<TX>, Y: Array1<TY>> SupervisedEstimator<X, Y, BernoulliNBParameters<TX>> for BernoulliNB<TX, TY, X, Y>
impl<TX: Number + PartialOrd, TY: Number + Ord + Unsigned, X: Array2<TX>, Y: Array1<TY>> SupervisedEstimator<X, Y, BernoulliNBParameters<TX>> for BernoulliNB<TX, TY, X, Y>
impl<TX: Number + PartialOrd, TY: Number + Ord + Unsigned, X: Array2<TX>, Y: Array1<TY>> StructuralPartialEq for BernoulliNB<TX, TY, X, Y>
Auto Trait Implementations§
impl<TX, TY, X, Y> RefUnwindSafe for BernoulliNB<TX, TY, X, Y>where TX: RefUnwindSafe, TY: RefUnwindSafe, X: RefUnwindSafe, Y: RefUnwindSafe,
impl<TX, TY, X, Y> Send for BernoulliNB<TX, TY, X, Y>where TX: Send, TY: Send, X: Send, Y: Send,
impl<TX, TY, X, Y> Sync for BernoulliNB<TX, TY, X, Y>where TX: Sync, TY: Sync, X: Sync, Y: Sync,
impl<TX, TY, X, Y> Unpin for BernoulliNB<TX, TY, X, Y>where TX: Unpin, TY: Unpin, X: Unpin, Y: Unpin,
impl<TX, TY, X, Y> UnwindSafe for BernoulliNB<TX, TY, X, Y>where TX: UnwindSafe, TY: UnwindSafe, X: UnwindSafe, Y: UnwindSafe,
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