Feature selector
fyt.core.feature_selection.feature_selector
¶
FeatureSelector
¶
Bases: BaseEstimator, TransformerMixin
FeatureSelector class that builds and runs a scikit-learn pipeline for feature selection.
random_state
property
writable
¶
The random state.
__init__(config, numerical_columns=None, categorical_columns=None, random_state=42)
¶
Initialize the FeatureSelector.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
config
|
FeatureSelectorConfig
|
Configuration for feature selection. |
required |
numerical_columns
|
list[str] | None
|
List of numerical column names. |
None
|
categorical_columns
|
list[str] | None
|
List of categorical column names. |
None
|
random_state
|
int
|
Random state for reproducibility. |
42
|
fit(X, y=None)
¶
Fit the feature selection pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
DataFrame | DataFrame
|
Input features. |
required |
y
|
Series | Series | ndarray | None
|
Target variable (required for supervised feature selection). |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
FeatureSelector |
FeatureSelector
|
Fitted FeatureSelector instance. |
get_feature_names_out(input_features=None)
¶
Get feature names after selection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_features
|
Sequence[str] | ndarray | None
|
Input feature names. |
None
|
Returns:
| Type | Description |
|---|---|
|
Array of feature names after selection. |
Raises:
| Type | Description |
|---|---|
NotFittedError
|
If the selector is not fitted and no |
get_support(indices=False)
¶
Get a mask, or integer index, of the features selected.
The mask is derived from the feature names surviving the whole pipeline
(via get_feature_names_out), so it accounts for every step, including
those without a get_support method such as the correlation filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
indices
|
bool
|
If True, return integer indices of selected features. |
False
|
Returns:
| Type | Description |
|---|---|
|
Boolean mask or integer indices of selected features. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the FeatureSelector has not been fitted yet, or if no
pipeline step exposes |
transform(X)
¶
Transform the data using the fitted pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
DataFrame | DataFrame
|
Input features to transform. |
required |
Returns:
| Type | Description |
|---|---|
|
Transformed features with selected subset. |