pub struct MutualInformationSelector {
pub n_features_to_select: usize,
pub n_bins: usize,
}Expand description
Parameters for MutualInformationSelector (unfitted state).
Selects the top-k features by mutual information with the target variable. Mutual information measures the dependency between two variables: a higher score means the feature is more informative about the target.
For continuous features, values are discretized into equal-width bins before
computing mutual information. The number of bins can be tuned via n_bins.
This is a supervised feature selector and requires target labels y.
§Example
use anofox_ml_preprocessing::MutualInformationSelector;
use anofox_ml_core::{Fit, Transform};
use ndarray::array;
let x = array![
[1.0, 100.0],
[2.0, 200.0],
[1.0, 300.0],
[2.0, 400.0],
];
let y = array![0.0, 1.0, 0.0, 1.0]; // perfectly correlated with col 0
let selector = MutualInformationSelector::new(1);
let fitted = Fit::<f64>::fit(&selector, &x, &y).unwrap();
let x_selected = fitted.transform(&x).unwrap();
assert_eq!(x_selected.ncols(), 1);Fields§
§n_features_to_select: usizeNumber of top features to select.
n_bins: usizeNumber of equal-width bins for discretizing continuous features.
Implementations§
Trait Implementations§
Source§impl Clone for MutualInformationSelector
impl Clone for MutualInformationSelector
Source§fn clone(&self) -> MutualInformationSelector
fn clone(&self) -> MutualInformationSelector
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 MutualInformationSelector
impl Debug for MutualInformationSelector
Source§impl<'de> Deserialize<'de> for MutualInformationSelector
impl<'de> Deserialize<'de> for MutualInformationSelector
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> Fit<F> for MutualInformationSelector
impl<F: Float> Fit<F> for MutualInformationSelector
Auto Trait Implementations§
impl Freeze for MutualInformationSelector
impl RefUnwindSafe for MutualInformationSelector
impl Send for MutualInformationSelector
impl Sync for MutualInformationSelector
impl Unpin for MutualInformationSelector
impl UnsafeUnpin for MutualInformationSelector
impl UnwindSafe for MutualInformationSelector
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