Skip to content

feature_selection

feature_selection

feature_selection(
    estimator: BaseEstimator,
    X: ndarray,
    y: ndarray,
    n_features_to_select: int = 3,
    feature_names: list[str] | None = None,
    **kwargs
) -> SequentialFeatureSelector

Perform feature selection to find the most important features.

Uses forward sequential feature selection to identify the most important features for the given estimator and data.

Parameters:

Name Type Description Default
estimator BaseEstimator

The model to use for feature selection

required
X ndarray

Input features, shape (n_samples, n_features)

required
y ndarray

Target values, shape (n_samples,)

required
n_features_to_select int

Number of features to select

3
feature_names list[str] | None

Names of the features (optional)

None
**kwargs

Additional parameters to pass to SequentialFeatureSelector

{}

Returns:

Name Type Description
SequentialFeatureSelector SequentialFeatureSelector

Fitted feature selector that can be used to transform data to use only the selected features