Struct smartcore::naive_bayes::categorical::CategoricalNB
source · pub struct CategoricalNB<T: Number + Unsigned, X: Array2<T>, Y: Array1<T>> { /* private fields */ }
Expand description
CategoricalNB implements the categorical naive Bayes algorithm for categorically distributed data.
Implementations§
source§impl<T: Number + Unsigned, X: Array2<T>, Y: Array1<T>> CategoricalNB<T, X, Y>
impl<T: Number + Unsigned, X: Array2<T>, Y: Array1<T>> CategoricalNB<T, X, Y>
sourcepub fn fit(
x: &X,
y: &Y,
parameters: CategoricalNBParameters
) -> Result<Self, Failed>
pub fn fit( x: &X, y: &Y, parameters: CategoricalNBParameters ) -> Result<Self, Failed>
Fits CategoricalNB 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 alpha for smoothing
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<T>
pub fn classes(&self) -> &Vec<T>
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 n_categories(&self) -> &Vec<usize>
pub fn n_categories(&self) -> &Vec<usize>
Number of features of each sample
Trait Implementations§
source§impl<T: Debug + Number + Unsigned, X: Debug + Array2<T>, Y: Debug + Array1<T>> Debug for CategoricalNB<T, X, Y>
impl<T: Debug + Number + Unsigned, X: Debug + Array2<T>, Y: Debug + Array1<T>> Debug for CategoricalNB<T, X, Y>
source§impl<T: PartialEq + Number + Unsigned, X: PartialEq + Array2<T>, Y: PartialEq + Array1<T>> PartialEq<CategoricalNB<T, X, Y>> for CategoricalNB<T, X, Y>
impl<T: PartialEq + Number + Unsigned, X: PartialEq + Array2<T>, Y: PartialEq + Array1<T>> PartialEq<CategoricalNB<T, X, Y>> for CategoricalNB<T, X, Y>
source§fn eq(&self, other: &CategoricalNB<T, X, Y>) -> bool
fn eq(&self, other: &CategoricalNB<T, X, Y>) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl<T: Number + Unsigned, X: Array2<T>, Y: Array1<T>> Predictor<X, Y> for CategoricalNB<T, X, Y>
impl<T: Number + Unsigned, X: Array2<T>, Y: Array1<T>> Predictor<X, Y> for CategoricalNB<T, X, Y>
source§impl<T: Number + Unsigned, X: Array2<T>, Y: Array1<T>> SupervisedEstimator<X, Y, CategoricalNBParameters> for CategoricalNB<T, X, Y>
impl<T: Number + Unsigned, X: Array2<T>, Y: Array1<T>> SupervisedEstimator<X, Y, CategoricalNBParameters> for CategoricalNB<T, X, Y>
impl<T: Number + Unsigned, X: Array2<T>, Y: Array1<T>> StructuralPartialEq for CategoricalNB<T, X, Y>
Auto Trait Implementations§
impl<T, X, Y> RefUnwindSafe for CategoricalNB<T, X, Y>where T: RefUnwindSafe, X: RefUnwindSafe, Y: RefUnwindSafe,
impl<T, X, Y> Send for CategoricalNB<T, X, Y>where T: Send, X: Send, Y: Send,
impl<T, X, Y> Sync for CategoricalNB<T, X, Y>where T: Sync, X: Sync, Y: Sync,
impl<T, X, Y> Unpin for CategoricalNB<T, X, Y>where T: Unpin, X: Unpin, Y: Unpin,
impl<T, X, Y> UnwindSafe for CategoricalNB<T, X, Y>where T: 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