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§
Source§impl MutualInformationSelector
impl MutualInformationSelector
Sourcepub fn new(n_features_to_select: usize) -> MutualInformationSelector
pub fn new(n_features_to_select: usize) -> MutualInformationSelector
Create a new selector that keeps the top n_features_to_select features.
Sourcepub fn with_n_bins(self, n_bins: usize) -> MutualInformationSelector
pub fn with_n_bins(self, n_bins: usize) -> MutualInformationSelector
Set the number of bins for discretizing continuous features.
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<MutualInformationSelector, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<MutualInformationSelector, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<F> Fit<F> for MutualInformationSelectorwhere
F: Float,
impl<F> Fit<F> for MutualInformationSelectorwhere
F: Float,
Source§impl Serialize for MutualInformationSelector
impl Serialize for MutualInformationSelector
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> SendAlias 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.