ArbitraryOutlierCapper

class feature_engine.outliers.ArbitraryOutlierCapper(max_capping_dict=None, min_capping_dict=None, missing_values='raise')[source]

The ArbitraryOutlierCapper() caps the maximum or minimum values of a variable at an arbitrary value indicated by the user.

You must provide the maximum or minimum values that will be used to cap each variable in a dictionary {feature:capping value}

More details in the User Guide.

Parameters
max_capping_dict: dictionary, default=None

Dictionary containing the user specified capping values for the right tail of the distribution of each variable (maximum values).

min_capping_dict: dictionary, default=None

Dictionary containing user specified capping values for the eft tail of the distribution of each variable (minimum values).

missing_valuesstring, default=’raise’

Indicates if missing values should be ignored or raised. If missing_values='raise' the transformer will return an error if the training or the datasets to transform contain missing values.

Attributes
right_tail_caps_:

Dictionary with the maximum values at which variables will be capped.

left_tail_caps_:

Dictionary with the minimum values at which variables will be capped.

variables_:

The group of variables that will be transformed.

n_features_in_:

The number of features in the train set used in fit.

Methods

fit:

This transformer does not learn any parameter.

transform:

Cap the variables.

fit_transform:

Fit to the data. Then transform it.

fit(X, y=None)[source]

This transformer does not learn any parameter.

Parameters
X: pandas dataframe of shape = [n_samples, n_features]

The training input samples.

y: pandas Series, default=None

y is not needed in this transformer. You can pass y or None.

fit_transform(X, y=None, **fit_params)[source]

Fit to data, then transform it.

Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.

Parameters
Xarray-like of shape (n_samples, n_features)

Input samples.

yarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None

Target values (None for unsupervised transformations).

**fit_paramsdict

Additional fit parameters.

Returns
X_newndarray array of shape (n_samples, n_features_new)

Transformed array.

get_params(deep=True)[source]

Get parameters for this estimator.

Parameters
deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns
paramsdict

Parameter names mapped to their values.

set_params(**params)[source]

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as Pipeline). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Parameters
**paramsdict

Estimator parameters.

Returns
selfestimator instance

Estimator instance.

transform(X)[source]

Cap the variable values.

Parameters
X: pandas dataframe of shape = [n_samples, n_features]

The data to be transformed.

Returns
X_new: pandas dataframe of shape = [n_samples, n_features]

The dataframe with the capped variables.

rtype

DataFrame ..