SklearnTransform

class SklearnTransform(in_column: Optional[Union[str, List[str]]], out_column: Optional[str], transformer: sklearn.base.TransformerMixin, inplace: bool = True, mode: Union[etna.transforms.math.sklearn.TransformMode, str] = 'per-segment')[source]

Bases: etna.transforms.base.ReversibleTransform

Base class for different sklearn transforms.

Init SklearnTransform.

Parameters
  • in_column (Optional[Union[str, List[str]]]) – columns to be transformed, if None - all columns will be transformed.

  • transformer (sklearn.base.TransformerMixin) – sklearn.base.TransformerMixin instance.

  • inplace (bool) – features are changed by transformed.

  • out_column (Optional[str]) – base for the names of generated columns, uses self.__repr__() if not given.

  • mode (Union[etna.transforms.math.sklearn.TransformMode, str]) –

    “macro” or “per-segment”, way to transform features over segments.

    • If “macro”, transforms features globally, gluing the corresponding ones for all segments.

    • If “per-segment”, transforms features for each segment separately.

Raises

ValueError: – if incorrect mode given

Inherited-members

Methods

fit(ts)

Fit the transform.

fit_transform(ts)

Fit and transform TSDataset.

get_regressors_info()

Return the list with regressors created by the transform.

inverse_transform(ts)

Inverse transform TSDataset.

load(path)

Load an object.

params_to_tune()

Get default grid for tuning hyperparameters.

save(path)

Save the object.

set_params(**params)

Return new object instance with modified parameters.

to_dict()

Collect all information about etna object in dict.

transform(ts)

Transform TSDataset inplace.

fit(ts: etna.datasets.tsdataset.TSDataset) etna.transforms.math.sklearn.SklearnTransform[source]

Fit the transform.

Parameters

ts (etna.datasets.tsdataset.TSDataset) –

Return type

etna.transforms.math.sklearn.SklearnTransform

get_regressors_info() List[str][source]

Return the list with regressors created by the transform.

Return type

List[str]

params_to_tune() Dict[str, etna.distributions.distributions.BaseDistribution][source]

Get default grid for tuning hyperparameters.

This grid tunes mode parameter. Other parameters are expected to be set by the user.

Returns

Grid to tune.

Return type

Dict[str, etna.distributions.distributions.BaseDistribution]