energy_fault_detector.data_preprocessing.column_selector
- class ColumnSelector(max_nan_frac_per_col=0.05, features_to_exclude=None, features_to_select=None)[source]
Bases:
DataTransformerClass for selecting columns, using the provided list of features to exclude/drop and the fraction of NaNs.
- Parameters:
max_nan_frac_per_col (
float) – maximum fraction of NaN values allowed per column. Defaults to 0.05. If the fraction exceeds max_nan_frac_per_col, the column is dropped.features_to_exclude (
Optional[List[str]]) – columns to drop (case-insensitive).features_to_select (
Optional[List[str]]) – columns to keep (case-insensitive). Mutually exclusive with features_to_exclude.
- feature_names_in_
list of column names in input.
- n_features_in_
number of columns in input.
- feature_names_out_
list of column names to keep / selected.
- columns_dropped_
list of columns that were dropped.
- fit(x, y=None, protected_features=None)[source]
Find columns to keep for training
- Parameters:
x (
DataFrame) – data to filter based on NaN fractionsy (
Optional[array]) – target variable, currently unused.protected_features (
Optional[List[str]]) – list of feature names that should never be dropped (e.g., conditional features for autoencoders). Warnings will be issued if these features would have been dropped otherwise.
- Return type:
- get_feature_names_out(input_features=None)[source]
Returns the list of feature names in the output.
- Return type:
List[str]
- inverse_transform(x)[source]
Inverse transform does nothing in case of column selector - since the columns dropped are not reconstructed.
- Return type:
DataFrame
- set_fit_request(*, protected_features: bool | None | str = '$UNCHANGED$', x: bool | None | str = '$UNCHANGED$') ColumnSelector
Request metadata passed to the
fitmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed tofitif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it tofit.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.Parameters
- protected_featuresstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
protected_featuresparameter infit.- xstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
xparameter infit.
Returns
- selfobject
The updated object.
- set_inverse_transform_request(*, x: bool | None | str = '$UNCHANGED$') ColumnSelector
Request metadata passed to the
inverse_transformmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed toinverse_transformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it toinverse_transform.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.Parameters
- xstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
xparameter ininverse_transform.
Returns
- selfobject
The updated object.
- set_transform_request(*, x: bool | None | str = '$UNCHANGED$') ColumnSelector
Request metadata passed to the
transformmethod.Note that this method is only relevant if
enable_metadata_routing=True(seesklearn.set_config()). Please see User Guide on how the routing mechanism works.The options for each parameter are:
True: metadata is requested, and passed totransformif provided. The request is ignored if metadata is not provided.False: metadata is not requested and the meta-estimator will not pass it totransform.None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.str: metadata should be passed to the meta-estimator with this given alias instead of the original name.
The default (
sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.Added in version 1.3.
Note
This method is only relevant if this estimator is used as a sub-estimator of a meta-estimator, e.g. used inside a
Pipeline. Otherwise it has no effect.Parameters
- xstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED
Metadata routing for
xparameter intransform.
Returns
- selfobject
The updated object.