pub enum ClassWeight<F> {
None,
Balanced,
Explicit(Vec<(usize, F)>),
}Expand description
Per-class weighting strategy for LinearSVC.
Mirrors sklearn.svm.LinearSVC’s class_weight parameter
(sklearn/svm/_classes.py:118-124, constraint {None, dict, 'balanced'}):
it scales the inverse-regularization C per class so the effective penalty
for class i is class_weight[i]·C (compute_class_weight,
sklearn/svm/_base.py:1179; weighted_C[i] = C·class_weight[i],
liblinear/linear.cpp:2496-2507). The expanded per-class weights are
computed by [compute_class_weight] following
sklearn.utils.compute_class_weight semantics
(sklearn/utils/class_weight.py:63-81).
This mirrors ferrolearn_linear::sgd::ClassWeight for cross-estimator
consistency, but is defined locally (no cross-import of sgd internals).
Variants§
None
Uniform weights (all classes weighted 1.0). The default
(class_weight=None, class_weight.py:63-65).
Balanced
Balanced weights n_samples / (n_classes · count_c) per class c,
matching sklearn.utils.compute_class_weight("balanced", ...)
(class_weight.py:66-74).
Explicit(Vec<(usize, F)>)
Explicit class-label -> weight map. Classes absent from the map default
to 1.0, matching the dict branch of compute_class_weight
(class_weight.py:75-81).
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> Default for ClassWeight<F>
impl<F> Default for ClassWeight<F>
Source§fn default() -> ClassWeight<F>
fn default() -> 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