pub struct SelectFromModelExt<F> { /* private fields */ }Expand description
An extended model-importance-based feature selector.
Like SelectFromModel but
supports four threshold strategies and an optional max_features cap.
§Examples
use ferrolearn_preprocess::select_from_model::{SelectFromModelExt, ThresholdStrategy};
use ferrolearn_core::traits::{Fit, Transform};
use ndarray::array;
let sel = SelectFromModelExt::<f64>::new(ThresholdStrategy::Mean, None);
let importances = array![0.1, 0.5, 0.4];
let fitted = sel.fit(&importances, &()).unwrap();
let x = array![[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]];
let out = fitted.transform(&x).unwrap();
// Mean importance = (0.1+0.5+0.4)/3 ≈ 0.333; columns 1 and 2 kept
assert_eq!(out.ncols(), 2);Implementations§
Source§impl<F: Float + Send + Sync + 'static> SelectFromModelExt<F>
impl<F: Float + Send + Sync + 'static> SelectFromModelExt<F>
Sourcepub fn new(threshold: ThresholdStrategy, max_features: Option<usize>) -> Self
pub fn new(threshold: ThresholdStrategy, max_features: Option<usize>) -> Self
Create a new SelectFromModelExt.
§Parameters
threshold— the strategy for computing the importance threshold.max_features— optional maximum number of features to retain.
Sourcepub fn threshold_strategy(&self) -> ThresholdStrategy
pub fn threshold_strategy(&self) -> ThresholdStrategy
Return the threshold strategy.
Sourcepub fn max_features(&self) -> Option<usize>
pub fn max_features(&self) -> Option<usize>
Return the maximum number of features (if set).
Trait Implementations§
Source§impl<F: Clone> Clone for SelectFromModelExt<F>
impl<F: Clone> Clone for SelectFromModelExt<F>
Source§fn clone(&self) -> SelectFromModelExt<F>
fn clone(&self) -> SelectFromModelExt<F>
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<F: Debug> Debug for SelectFromModelExt<F>
impl<F: Debug> Debug for SelectFromModelExt<F>
Source§impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>, ()> for SelectFromModelExt<F>
impl<F: Float + Send + Sync + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>, ()> for SelectFromModelExt<F>
Source§fn fit(
&self,
x: &Array1<F>,
_y: &(),
) -> Result<FittedSelectFromModelExt<F>, FerroError>
fn fit( &self, x: &Array1<F>, _y: &(), ) -> Result<FittedSelectFromModelExt<F>, FerroError>
Fit by computing the threshold from the given feature importances.
§Parameters
x— per-feature importance scores (one value per feature)._y— ignored (unsupervised).
§Errors
FerroError::InvalidParameterif the importance vector is empty, or ifPercentilevalue is not in(0, 100].
Source§type Fitted = FittedSelectFromModelExt<F>
type Fitted = FittedSelectFromModelExt<F>
The fitted model type returned by
fit.Source§type Error = FerroError
type Error = FerroError
The error type returned by
fit.Auto Trait Implementations§
impl<F> Freeze for SelectFromModelExt<F>
impl<F> RefUnwindSafe for SelectFromModelExt<F>where
F: RefUnwindSafe,
impl<F> Send for SelectFromModelExt<F>where
F: Send,
impl<F> Sync for SelectFromModelExt<F>where
F: Sync,
impl<F> Unpin for SelectFromModelExt<F>where
F: Unpin,
impl<F> UnsafeUnpin for SelectFromModelExt<F>
impl<F> UnwindSafe for SelectFromModelExt<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,
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>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§unsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.