energy_fault_detector.data_preprocessing.data_clipper

Clip data before standardization or normalization

class DataClipper(lower_percentile=0.01, upper_percentile=0.99, features_to_exclude=None, features_to_clip=None)[source]

Bases: DataTransformer

Clip data to remove outliers.

Parameters:
  • lower_percentile (float) – The lower percentile for clipping (default: 0.01).

  • upper_percentile (float) – The upper percentile for clipping (default: 0.99).

  • features_to_exclude (Optional[List[str]]) – Column names that should not be clipped.

  • features_to_clip (Optional[List[str]]) – Column names that should be clipped (mutually exclusive with features_to_exclude).

Configuration example:

train:
  data_clipping:
    lower_percentile: 0.001
    upper_percentile: 0.999
    features_to_exclude:   # or use features_to_clip
      - do_not_clip_this_feature
fit(x, y=None)[source]

Set feature names in and out.

Return type:

DataClipper

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]

Not implemented for data clipper (not useful)

Return type:

DataFrame

set_fit_request(*, x: bool | None | str = '$UNCHANGED$') DataClipper

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

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$') DataClipper

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$') DataClipper

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]

Clips the data to remove outliers, excluding angles.

Parameters:

x (DataFrame) – The input DataFrame.

Returns:

The clipped DataFrame.

Return type:

DataFrame