#[non_exhaustive]pub struct VarianceThreshold { /* private fields */ }Expand description
Remove features whose variance falls below a threshold.
By default, removes only constant features (threshold = 0.0). Useful as a lightweight first step before expensive feature selectors.
§Examples
use scry_learn::dataset::Dataset;
use scry_learn::preprocess::Transformer;
use scry_learn::feature_selection::VarianceThreshold;
let mut data = Dataset::new(
vec![
vec![1.0, 2.0, 3.0], // variable
vec![5.0, 5.0, 5.0], // constant — will be removed
],
vec![0.0, 1.0, 0.0],
vec!["a".into(), "b".into()],
"target",
);
let mut vt = VarianceThreshold::new();
vt.fit_transform(&mut data).unwrap();
assert_eq!(data.n_features(), 1); // only "a" remainsImplementations§
Source§impl VarianceThreshold
impl VarianceThreshold
Trait Implementations§
Source§impl Clone for VarianceThreshold
impl Clone for VarianceThreshold
Source§fn clone(&self) -> VarianceThreshold
fn clone(&self) -> VarianceThreshold
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for VarianceThreshold
impl Debug for VarianceThreshold
Source§impl Default for VarianceThreshold
impl Default for VarianceThreshold
Auto Trait Implementations§
impl Freeze for VarianceThreshold
impl RefUnwindSafe for VarianceThreshold
impl Send for VarianceThreshold
impl Sync for VarianceThreshold
impl Unpin for VarianceThreshold
impl UnsafeUnpin for VarianceThreshold
impl UnwindSafe for VarianceThreshold
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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