pub enum ClassWeight<F> {
None,
Balanced,
Explicit(Vec<(usize, F)>),
}Expand description
Per-class weighting for DecisionTreeClassifier.
Mirrors sklearn.tree.DecisionTreeClassifier’s class_weight parameter
(sklearn/tree/_classes.py:801-820, constraint
{dict, list, 'balanced', None}, _classes.py:942). sklearn expands
class_weight to PER-SAMPLE weights via
compute_sample_weight(class_weight, y) and folds them into the tree’s
sample_weight (_classes.py:310-367); every weighted quantity (node class
counts, gini/entropy, the leaf value_/predict_proba, and the
min_weight_fraction_leaf gate) is then computed on those weights.
Mirrors ferrolearn_linear::svm::ClassWeight for cross-estimator
consistency, but is defined locally (no cross-crate import). DecisionTreeRegressor
has NO class_weight (sklearn _classes.py:1317), so this lives only on the
classifier.
Variants§
None
Uniform weights (all classes weighted 1.0). The default
(class_weight=None). Produces a byte-identical tree to the unweighted
build.
Balanced
Balanced weights n_samples / (n_classes · count_c) per class c,
matching sklearn.utils.compute_class_weight("balanced", ...)
(class_weight.py:72: 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
(class_weight.py:74-86).
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>
Source§impl<'de, F> Deserialize<'de> for ClassWeight<F>where
F: Deserialize<'de>,
impl<'de, F> Deserialize<'de> for ClassWeight<F>where
F: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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 ==.Source§impl<F> Serialize for ClassWeight<F>where
F: Serialize,
impl<F> Serialize for ClassWeight<F>where
F: Serialize,
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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