pub struct VarianceThreshold<F> { /* private fields */ }Expand description
An unfitted variance-threshold feature selector.
During fitting the population variance of every column is computed (NaN values are treated as zero — use an imputer upstream if needed). Columns whose variance is less than or equal to the configured threshold are discarded during transformation.
The default threshold is 0.0, which removes features with exactly zero
variance (i.e. constant columns).
§Examples
use ferrolearn_preprocess::feature_selection::VarianceThreshold;
use ferrolearn_core::traits::{Fit, Transform};
use ndarray::array;
let sel = VarianceThreshold::<f64>::new(0.0);
// Column 1 is constant — will be removed
let x = array![[1.0, 7.0], [2.0, 7.0], [3.0, 7.0]];
let fitted = sel.fit(&x, &()).unwrap();
let out = fitted.transform(&x).unwrap();
assert_eq!(out.ncols(), 1);Implementations§
Trait Implementations§
Source§impl<F: Clone> Clone for VarianceThreshold<F>
impl<F: Clone> Clone for VarianceThreshold<F>
Source§fn clone(&self) -> VarianceThreshold<F>
fn clone(&self) -> VarianceThreshold<F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<F: Debug> Debug for VarianceThreshold<F>
impl<F: Debug> Debug for VarianceThreshold<F>
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for VarianceThreshold<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for VarianceThreshold<F>
Source§fn fit(
&self,
x: &Array2<F>,
_y: &(),
) -> Result<FittedVarianceThreshold<F>, FerroError>
fn fit( &self, x: &Array2<F>, _y: &(), ) -> Result<FittedVarianceThreshold<F>, FerroError>
Fit by computing per-column population variances.
§Errors
Returns FerroError::InsufficientSamples if the input has zero rows.
Returns FerroError::InvalidParameter if the threshold is negative.
Source§type Fitted = FittedVarianceThreshold<F>
type Fitted = FittedVarianceThreshold<F>
The fitted model type returned by
fit.Source§type Error = FerroError
type Error = FerroError
The error type returned by
fit.Source§impl PipelineTransformer<f64> for VarianceThreshold<f64>
impl PipelineTransformer<f64> for VarianceThreshold<f64>
Source§fn fit_pipeline(
&self,
x: &Array2<f64>,
_y: &Array1<f64>,
) -> Result<Box<dyn FittedPipelineTransformer<f64>>, FerroError>
fn fit_pipeline( &self, x: &Array2<f64>, _y: &Array1<f64>, ) -> Result<Box<dyn FittedPipelineTransformer<f64>>, FerroError>
Auto Trait Implementations§
impl<F> Freeze for VarianceThreshold<F>where
F: Freeze,
impl<F> RefUnwindSafe for VarianceThreshold<F>where
F: RefUnwindSafe,
impl<F> Send for VarianceThreshold<F>where
F: Send,
impl<F> Sync for VarianceThreshold<F>where
F: Sync,
impl<F> Unpin for VarianceThreshold<F>where
F: Unpin,
impl<F> UnsafeUnpin for VarianceThreshold<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for VarianceThreshold<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
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> 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