Struct linfa_bayes::GaussianNb
source · [−]pub struct GaussianNb<F, L> { /* private fields */ }
Expand description
Fitted Gaussian Naive Bayes classifier
See GaussianNbParams for more information on the hyper-parameters.
Model assumptions
The family of naive bayes classifiers assume independence between variables. They do not model moments between variables and lack therefore in modelling capability. The advantage is a linear fitting time with maximum-likelihood training in a closed form.
Model estimation
You can fit a single model from a dataset
use linfa::traits::Fit;
let model = GaussianNb::params().fit(&ds)?;
or incrementally update a model
use linfa::traits::FitWith;
let clf = GaussianNb::params();
let model = datasets.iter()
.try_fold(None, |prev_model, &ds| clf.fit_with(prev_model, ds))?
.unwrap();
After fitting the model, you can use the Predict
variants to
predict new targets.
Implementations
sourceimpl<F: Float, L: Label> GaussianNb<F, L>
impl<F: Float, L: Label> GaussianNb<F, L>
sourcepub fn params() -> GaussianNbParams<F, L>
pub fn params() -> GaussianNbParams<F, L>
Construct a new set of hyperparameters
Trait Implementations
sourceimpl<F: Clone, L: Clone> Clone for GaussianNb<F, L>
impl<F: Clone, L: Clone> Clone for GaussianNb<F, L>
sourcefn clone(&self) -> GaussianNb<F, L>
fn clone(&self) -> GaussianNb<F, L>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<F: Debug, L: Debug> Debug for GaussianNb<F, L>
impl<F: Debug, L: Debug> Debug for GaussianNb<F, L>
sourceimpl<F: Float, L: Label, D> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<L>, Dim<[usize; 1]>>> for GaussianNb<F, L> where
D: Data<Elem = F>,
impl<F: Float, L: Label, D> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<L>, Dim<[usize; 1]>>> for GaussianNb<F, L> where
D: Data<Elem = F>,
sourcefn predict_inplace(&self, x: &ArrayBase<D, Ix2>, y: &mut Array1<L>)
fn predict_inplace(&self, x: &ArrayBase<D, Ix2>, y: &mut Array1<L>)
Predict something in place
sourcefn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<L>
fn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<L>
Create targets that predict_inplace
works with.
Auto Trait Implementations
impl<F, L> RefUnwindSafe for GaussianNb<F, L> where
F: RefUnwindSafe,
L: RefUnwindSafe,
impl<F, L> Send for GaussianNb<F, L> where
F: Send,
L: Send,
impl<F, L> Sync for GaussianNb<F, L> where
F: Sync,
L: Sync,
impl<F, L> Unpin for GaussianNb<F, L> where
F: Unpin,
L: Unpin,
impl<F, L> UnwindSafe for GaussianNb<F, L> where
F: UnwindSafe + RefUnwindSafe,
L: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<'a, F, D, DM, T, O> Predict<&'a ArrayBase<D, DM>, T> for O where
D: Data<Elem = F>,
DM: Dimension,
O: PredictInplace<ArrayBase<D, DM>, T>,
impl<'a, F, D, DM, T, O> Predict<&'a ArrayBase<D, DM>, T> for O where
D: Data<Elem = F>,
DM: Dimension,
O: PredictInplace<ArrayBase<D, DM>, T>,
sourceimpl<'a, F, R, T, S, O> Predict<&'a DatasetBase<R, T>, S> for O where
R: Records<Elem = F>,
O: PredictInplace<R, S>,
impl<'a, F, R, T, S, O> Predict<&'a DatasetBase<R, T>, S> for O where
R: Records<Elem = F>,
O: PredictInplace<R, S>,
pub fn predict(&self, ds: &'a DatasetBase<R, T>) -> S
sourceimpl<F, D, E, T, O> Predict<ArrayBase<D, Dim<[usize; 2]>>, DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>> for O where
D: Data<Elem = F>,
T: AsTargets<Elem = E>,
O: PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, T>,
impl<F, D, E, T, O> Predict<ArrayBase<D, Dim<[usize; 2]>>, DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>> for O where
D: Data<Elem = F>,
T: AsTargets<Elem = E>,
O: PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, T>,
sourceimpl<F, R, T, E, S, O> Predict<DatasetBase<R, T>, DatasetBase<R, S>> for O where
R: Records<Elem = F>,
S: AsTargets<Elem = E>,
O: PredictInplace<R, S>,
impl<F, R, T, E, S, O> Predict<DatasetBase<R, T>, DatasetBase<R, S>> for O where
R: Records<Elem = F>,
S: AsTargets<Elem = E>,
O: PredictInplace<R, S>,
pub fn predict(&self, ds: DatasetBase<R, T>) -> DatasetBase<R, S>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more