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: DataTransformer

Class 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 fractions

  • y (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:

ColumnSelector

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 fit method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to fit.

  • 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_features parameter in fit.

xstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for x parameter in fit.

Returns

selfobject

The updated object.

set_inverse_transform_request(*, x: bool | None | str = '$UNCHANGED$') ColumnSelector

Request metadata passed to the inverse_transform method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to inverse_transform if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to inverse_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 x parameter in inverse_transform.

Returns

selfobject

The updated object.

set_transform_request(*, x: bool | None | str = '$UNCHANGED$') ColumnSelector

Request metadata passed to the transform method.

Note that this method is only relevant if enable_metadata_routing=True (see sklearn.set_config()). Please see User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to transform if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to 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 x parameter in transform.

Returns

selfobject

The updated object.

transform(x)[source]

Drop columns from dataframe x.

Return type:

DataFrame