pub enum ClassWeight<F> {
Balanced,
Dict(Vec<(usize, F)>),
}Expand description
Per-class weighting strategy, mirroring scikit-learn’s class_weight
parameter (sklearn/linear_model/_logistic.py:1111,
"class_weight": [dict, StrOptions({"balanced"}), None]).
None (the absence of this enum) means uniform weights. The two non-uniform
modes both produce a per-class multiplier that is folded into the effective
per-sample weight sample_weight[i] * class_weight[y[i]]
(sklearn/linear_model/_logistic.py:312-313).
Variants§
Balanced
'balanced': per-class weight n_samples / (n_classes * bincount[class])
(sklearn/utils/class_weight.py:73,
recip_freq = len(y) / (len(le.classes_) * np.bincount(y_ind))).
Dict(Vec<(usize, F)>)
A user-supplied {class_label: weight} map. Classes absent from the map
default to weight 1.0 (sklearn/utils/class_weight.py:77-83). Stored as
(class_label, weight) pairs to preserve the F generic.
Trait Implementations§
Source§impl<F: Clone> Clone for ClassWeight<F>
impl<F: Clone> Clone for ClassWeight<F>
Source§fn clone(&self) -> ClassWeight<F>
fn clone(&self) -> ClassWeight<F>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug> Debug for ClassWeight<F>
impl<F: Debug> Debug for ClassWeight<F>
Source§impl<F: PartialEq> PartialEq for ClassWeight<F>
impl<F: PartialEq> PartialEq for ClassWeight<F>
Source§fn eq(&self, other: &ClassWeight<F>) -> bool
fn eq(&self, other: &ClassWeight<F>) -> bool
self and other values to be equal, and is used by ==.impl<F> StructuralPartialEq for ClassWeight<F>
Auto Trait Implementations§
impl<F> Freeze for ClassWeight<F>
impl<F> RefUnwindSafe for ClassWeight<F>where
F: RefUnwindSafe,
impl<F> Send for ClassWeight<F>where
F: Send,
impl<F> Sync for ClassWeight<F>where
F: Sync,
impl<F> Unpin for ClassWeight<F>where
F: Unpin,
impl<F> UnsafeUnpin for ClassWeight<F>
impl<F> UnwindSafe for ClassWeight<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
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,
impl<T, U> Imply<T> for U
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>
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>
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