pub struct VarianceThreshold {
pub threshold: f64,
}Expand description
Parameters for VarianceThreshold feature selector (unfitted state).
Removes all features whose variance does not meet a minimum threshold.
By default (threshold = 0.0), it removes features that have zero variance,
i.e., features that are constant across all samples.
This is a simple baseline approach to feature selection: a feature with higher variance is more likely to be informative (though this is not guaranteed).
§Example
use anofox_ml_preprocessing::VarianceThreshold;
use anofox_ml_core::{FitUnsupervised, Transform};
use ndarray::array;
let x = array![
[0.0, 2.0, 0.0],
[0.0, 4.0, 0.0],
[0.0, 6.0, 0.0],
];
// Remove zero-variance features (columns 0 and 2 are constant)
let selector = VarianceThreshold::new(0.0);
let fitted = FitUnsupervised::<f64>::fit(&selector, &x).unwrap();
let x_selected = fitted.transform(&x).unwrap();
assert_eq!(x_selected.ncols(), 1); // only the varying column survivesFields§
§threshold: f64Minimum variance required for a feature to be kept. Features with variance <= threshold are removed.
Implementations§
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
Source§impl<'de> Deserialize<'de> for VarianceThreshold
impl<'de> Deserialize<'de> for VarianceThreshold
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<F: Float> FitUnsupervised<F> for VarianceThreshold
impl<F: Float> FitUnsupervised<F> 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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,
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