pub struct ComplementNB<F> {
pub alpha: F,
pub class_prior: Option<Vec<F>>,
}Expand description
Complement Naive Bayes classifier.
A variant of Multinomial NB that uses complement-class statistics. More robust for imbalanced datasets.
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§alpha: FAdditive (Laplace) smoothing parameter. Default: 1.0.
class_prior: Option<Vec<F>>Optional user-supplied class priors. Note: ComplementNB does not use priors in the standard way (it uses complement weights), but this field is provided for API consistency with other NB variants.
Implementations§
Source§impl<F: Float> ComplementNB<F>
impl<F: Float> ComplementNB<F>
Sourcepub fn with_alpha(self, alpha: F) -> Self
pub fn with_alpha(self, alpha: F) -> Self
Set the Laplace smoothing parameter.
Sourcepub fn with_class_prior(self, priors: Vec<F>) -> Self
pub fn with_class_prior(self, priors: Vec<F>) -> Self
Set user-supplied class priors.
The priors must have length equal to the number of classes discovered during fitting. Note: ComplementNB uses complement-class weights rather than direct class priors, but the priors are stored for API consistency.
Trait Implementations§
Source§impl<F: Clone> Clone for ComplementNB<F>
impl<F: Clone> Clone for ComplementNB<F>
Source§fn clone(&self) -> ComplementNB<F>
fn clone(&self) -> ComplementNB<F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<F: Debug> Debug for ComplementNB<F>
impl<F: Debug> Debug for ComplementNB<F>
Source§impl<F: Float> Default for ComplementNB<F>
impl<F: Float> Default for ComplementNB<F>
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>> for ComplementNB<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>> for ComplementNB<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<usize>,
) -> Result<FittedComplementNB<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<usize>, ) -> Result<FittedComplementNB<F>, FerroError>
Fit the Complement NB model.
§Errors
FerroError::ShapeMismatchifxandyhave different numbers of rows.FerroError::InsufficientSamplesif there are no samples.FerroError::InvalidParameterif any feature value is negative.
Source§type Fitted = FittedComplementNB<F>
type Fitted = FittedComplementNB<F>
The fitted model type returned by
fit.Source§type Error = FerroError
type Error = FerroError
The error type returned by
fit.Source§impl<F: Float + ToPrimitive + FromPrimitive + Send + Sync + 'static> PipelineEstimator<F> for ComplementNB<F>
impl<F: Float + ToPrimitive + FromPrimitive + Send + Sync + 'static> PipelineEstimator<F> for ComplementNB<F>
Source§fn fit_pipeline(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<Box<dyn FittedPipelineEstimator<F>>, FerroError>
fn fit_pipeline( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<Box<dyn FittedPipelineEstimator<F>>, FerroError>
Fit this estimator on the given data. Read more
Auto Trait Implementations§
impl<F> Freeze for ComplementNB<F>where
F: Freeze,
impl<F> RefUnwindSafe for ComplementNB<F>where
F: RefUnwindSafe,
impl<F> Send for ComplementNB<F>where
F: Send,
impl<F> Sync for ComplementNB<F>where
F: Sync,
impl<F> Unpin for ComplementNB<F>where
F: Unpin,
impl<F> UnsafeUnpin for ComplementNB<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for ComplementNB<F>where
F: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more