Struct linfa_bayes::GaussianNbParams [−][src]
Gaussian Naive Bayes (GaussianNB)
The Gaussian Naive Bayes is a classification algorithm where the likelihood of the feature P(x_i | y) is assumed to be Gaussian, features are assumed to be independent, and the mean and variance are estimated using maximum likelihood.
Implementations
impl GaussianNbParams
[src]
pub fn params() -> Self
[src]
Create new GaussianNB model with default values for its parameters
pub fn var_smoothing(self, var_smoothing: f64) -> Self
[src]
Specifies the portion of the largest variance of all the features that is added to the variance for calculation stability
Trait Implementations
impl Debug for GaussianNbParams
[src]
impl Default for GaussianNbParams
[src]
impl<F, D, L> Fit<'_, ArrayBase<D, Dim<[usize; 2]>>, L> for GaussianNbParams where
F: Float,
D: Data<Elem = F>,
L: AsTargets<Elem = usize> + Labels<Elem = usize>,
[src]
F: Float,
D: Data<Elem = F>,
L: AsTargets<Elem = usize> + Labels<Elem = usize>,
type Object = Result<GaussianNb<F>>
fn fit(&self, dataset: &DatasetBase<ArrayBase<D, Ix2>, L>) -> Self::Object
[src]
Fit the model
Example
let x = array![ [-2., -1.], [-1., -1.], [-1., -2.], [1., 1.], [1., 2.], [2., 1.] ]; let y = array![1, 1, 1, 2, 2, 2]; let data = Dataset::new(x, y); let model = GaussianNbParams::params().fit(&data)?; let pred = model.predict(&data); assert_abs_diff_eq!(pred, data.try_single_target()?);
impl<F, D, L> IncrementalFit<'_, ArrayBase<D, Dim<[usize; 2]>>, L> for GaussianNbParams where
F: Float,
D: Data<Elem = F>,
L: AsTargets<Elem = usize> + Labels<Elem = usize>,
[src]
F: Float,
D: Data<Elem = F>,
L: AsTargets<Elem = usize> + Labels<Elem = usize>,
type ObjectIn = Option<GaussianNb<F>>
type ObjectOut = Result<Option<GaussianNb<F>>>
fn fit_with(
&self,
model_in: Self::ObjectIn,
dataset: &DatasetBase<ArrayBase<D, Ix2>, L>
) -> Self::ObjectOut
[src]
&self,
model_in: Self::ObjectIn,
dataset: &DatasetBase<ArrayBase<D, Ix2>, L>
) -> Self::ObjectOut
Incrementally fit on a batch of samples
Example
let x = array![ [-2., -1.], [-1., -1.], [-1., -2.], [1., 1.], [1., 2.], [2., 1.] ]; let y = array![1, 1, 1, 2, 2, 2]; let mut clf = GaussianNbParams::params(); let mut model = None; for (x, y) in x .axis_chunks_iter(Axis(0), 2) .zip(y.axis_chunks_iter(Axis(0), 2)) { model = clf.fit_with(model, &DatasetView::new(x, y))?; } let pred = model.as_ref().unwrap().predict(&x); assert_abs_diff_eq!(pred, y);
Auto Trait Implementations
impl RefUnwindSafe for GaussianNbParams
impl Send for GaussianNbParams
impl Sync for GaussianNbParams
impl Unpin for GaussianNbParams
impl UnwindSafe for GaussianNbParams
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,