pub enum ClassWeight<F> {
None,
Balanced,
Explicit(Vec<(usize, F)>),
}Expand description
Per-class scaling of the regularization parameter C for SVC.
Mirrors sklearn.svm.SVC’s class_weight parameter
(sklearn/svm/_classes.py:118-124, constraint {None, dict, 'balanced'}):
it sets the C of class i to class_weight[i]·C (libsvm’s per-class
weighted_C[i] = C·class_weight_[i]). The expanded per-class weights are
computed by [compute_class_weight] following
sklearn.utils.compute_class_weight semantics, as called from
BaseSVC._validate_targets
(self.class_weight_ = compute_class_weight(self.class_weight, classes=cls, y=y_), sklearn/svm/_base.py:740).
This mirrors crate::linear_svc::ClassWeight for cross-estimator
consistency, but is defined locally (no cross-import of linear_svc
internals).
Variants§
None
Uniform weights (all classes weighted 1.0). The default
(class_weight=None).
Balanced
Balanced weights n_samples / (n_classes · count_c) per class c,
matching sklearn.utils.compute_class_weight("balanced", ...)
(_classes.py:122-124: n_samples / (n_classes * np.bincount(y))).
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.
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