pub struct FeatureUnion<State = Untrained> { /* private fields */ }Expand description
FeatureUnion concatenates the results of multiple transformers
Unlike ColumnTransformer which applies different transformers to different columns, FeatureUnion applies all transformers to the same input data and concatenates their outputs column-wise.
This is useful for creating feature combinations, such as applying both PCA and polynomial features to the same input.
Implementations§
Source§impl FeatureUnion<Untrained>
impl FeatureUnion<Untrained>
Sourcepub fn add_transformer<T>(self, name: &str, transformer: T) -> Selfwhere
T: TransformerWrapper + 'static,
pub fn add_transformer<T>(self, name: &str, transformer: T) -> Selfwhere
T: TransformerWrapper + 'static,
Add a transformer to the union
Sourcepub fn add_weighted_transformer<T>(
self,
name: &str,
transformer: T,
weight: Float,
) -> Selfwhere
T: TransformerWrapper + 'static,
pub fn add_weighted_transformer<T>(
self,
name: &str,
transformer: T,
weight: Float,
) -> Selfwhere
T: TransformerWrapper + 'static,
Add a weighted transformer to the union
Sourcepub fn validate_input(self, validate: bool) -> Self
pub fn validate_input(self, validate: bool) -> Self
Set input validation
Sourcepub fn preserve_order(self, preserve: bool) -> Self
pub fn preserve_order(self, preserve: bool) -> Self
Set whether to preserve transformer order
Sourcepub fn feature_selection(self, strategy: FeatureSelectionStrategy) -> Self
pub fn feature_selection(self, strategy: FeatureSelectionStrategy) -> Self
Set feature selection strategy
Sourcepub fn importance_method(self, method: FeatureImportanceMethod) -> Self
pub fn importance_method(self, method: FeatureImportanceMethod) -> Self
Set feature importance calculation method
Sourcepub fn enable_feature_selection(self, enable: bool) -> Self
pub fn enable_feature_selection(self, enable: bool) -> Self
Enable or disable feature selection
Source§impl FeatureUnion<Trained>
impl FeatureUnion<Trained>
Sourcepub fn n_features_in(&self) -> usize
pub fn n_features_in(&self) -> usize
Get the number of input features
Sourcepub fn n_features_out(&self) -> usize
pub fn n_features_out(&self) -> usize
Get the number of output features
Sourcepub fn get_transformers(&self) -> &Vec<FeatureUnionStep>
pub fn get_transformers(&self) -> &Vec<FeatureUnionStep>
Get the fitted transformers
Sourcepub fn get_weights(&self) -> &Vec<Float> ⓘ
pub fn get_weights(&self) -> &Vec<Float> ⓘ
Get the weights used for each transformer
Sourcepub fn get_selected_features(&self) -> Option<&Vec<usize>>
pub fn get_selected_features(&self) -> Option<&Vec<usize>>
Get the selected feature indices (if feature selection is enabled)
Sourcepub fn get_feature_importances(&self) -> Option<&Array1<Float>>
pub fn get_feature_importances(&self) -> Option<&Array1<Float>>
Get the feature importance scores (if feature selection is enabled)
Sourcepub fn n_features_selected(&self) -> usize
pub fn n_features_selected(&self) -> usize
Get the number of features that were selected
Sourcepub fn is_feature_selection_enabled(&self) -> bool
pub fn is_feature_selection_enabled(&self) -> bool
Check if feature selection is enabled
Trait Implementations§
Source§impl<State: Debug> Debug for FeatureUnion<State>
impl<State: Debug> Debug for FeatureUnion<State>
Source§impl Default for FeatureUnion<Untrained>
impl Default for FeatureUnion<Untrained>
Source§impl Estimator for FeatureUnion<Untrained>
impl Estimator for FeatureUnion<Untrained>
Source§type Config = FeatureUnionConfig
type Config = FeatureUnionConfig
Source§type Error = SklearsError
type Error = SklearsError
Source§fn validate_config(&self) -> Result<(), SklearsError>
fn validate_config(&self) -> Result<(), SklearsError>
Source§fn check_compatibility(
&self,
n_samples: usize,
n_features: usize,
) -> Result<(), SklearsError>
fn check_compatibility( &self, n_samples: usize, n_features: usize, ) -> Result<(), SklearsError>
Source§fn metadata(&self) -> EstimatorMetadata
fn metadata(&self) -> EstimatorMetadata
Source§impl Estimator for FeatureUnion<Trained>
impl Estimator for FeatureUnion<Trained>
Source§type Config = FeatureUnionConfig
type Config = FeatureUnionConfig
Source§type Error = SklearsError
type Error = SklearsError
Source§fn validate_config(&self) -> Result<(), SklearsError>
fn validate_config(&self) -> Result<(), SklearsError>
Source§fn check_compatibility(
&self,
n_samples: usize,
n_features: usize,
) -> Result<(), SklearsError>
fn check_compatibility( &self, n_samples: usize, n_features: usize, ) -> Result<(), SklearsError>
Source§fn metadata(&self) -> EstimatorMetadata
fn metadata(&self) -> EstimatorMetadata
Source§impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ()> for FeatureUnion<Untrained>
impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ()> for FeatureUnion<Untrained>
Source§type Fitted = FeatureUnion<Trained>
type Fitted = FeatureUnion<Trained>
Source§fn fit(self, x: &Array2<Float>, _y: &()) -> Result<Self::Fitted>
fn fit(self, x: &Array2<Float>, _y: &()) -> Result<Self::Fitted>
Source§fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
fn fit_with_validation(
self,
x: &X,
y: &Y,
_x_val: Option<&X>,
_y_val: Option<&Y>,
) -> Result<(Self::Fitted, FitMetrics), SklearsError>where
Self: Sized,
Auto Trait Implementations§
impl<State> Freeze for FeatureUnion<State>
impl<State = Untrained> !RefUnwindSafe for FeatureUnion<State>
impl<State> Send for FeatureUnion<State>where
State: Send,
impl<State> Sync for FeatureUnion<State>where
State: Sync,
impl<State> Unpin for FeatureUnion<State>where
State: Unpin,
impl<State = Untrained> !UnwindSafe for FeatureUnion<State>
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
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>
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>
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