Expand description
Class weighting for imbalanced datasets.
Provides the ClassWeight enum and compute_sample_weights function
to generate per-sample weights that compensate for class imbalance.
§Example
use scry_learn::weights::{ClassWeight, compute_sample_weights};
let targets = vec![0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0];
let weights = compute_sample_weights(&targets, &ClassWeight::Balanced);
// Minority class (1) gets higher weight to compensate for imbalance.
assert!(weights[9] > weights[0]);Enums§
- Class
Weight - Strategy for weighting classes during training.
Functions§
- compute_
sample_ weights - Compute per-sample weights from target labels and a class weighting strategy.