_OneSegmentSpecialDaysTransform

class _OneSegmentSpecialDaysTransform(find_special_weekday: bool = True, find_special_month_day: bool = True)[source]

Bases: etna.transforms.base.OneSegmentTransform

Search for anomalies in values, marked this days as 1 (and return new column with 1 in corresponding places).

Notes

You can read more about other anomalies detection methods in: Time Series of Price Anomaly Detection

Create instance of _OneSegmentSpecialDaysTransform.

Parameters
  • find_special_weekday (bool) – flag, if True, find special weekdays in transform

  • find_special_month_day (bool) – flag, if True, find special monthdays in transform

Raises

ValueError: – if all the modes are False

Inherited-members

Methods

fit(df)

Fit _OneSegmentSpecialDaysTransform with data from df.

fit_transform(df)

Fit and transform Dataframe.

inverse_transform(df)

Inverse transform Dataframe.

set_params(**params)

Return new object instance with modified parameters.

to_dict()

Collect all information about etna object in dict.

transform(df)

Transform data from df with _OneSegmentSpecialDaysTransform and generate a column of special day flags.

fit(df: pandas.core.frame.DataFrame) etna.transforms.timestamp.special_days._OneSegmentSpecialDaysTransform[source]

Fit _OneSegmentSpecialDaysTransform with data from df.

Parameters

df (pd.DataFrame) – value series with index column in timestamp format

Return type

etna.transforms.timestamp.special_days._OneSegmentSpecialDaysTransform

fit_transform(df: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame

Fit and transform Dataframe.

May be reimplemented. But it is not recommended.

Parameters

df (pandas.core.frame.DataFrame) – Dataframe in etna long format to transform.

Returns

Transformed Dataframe.

Return type

pandas.core.frame.DataFrame

inverse_transform(df: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame[source]

Inverse transform Dataframe.

Parameters

df (pandas.core.frame.DataFrame) –

Return type

pandas.core.frame.DataFrame

set_params(**params: dict) etna.core.mixins.TMixin

Return new object instance with modified parameters.

Method also allows to change parameters of nested objects within the current object. For example, it is possible to change parameters of a model in a Pipeline.

Nested parameters are expected to be in a <component_1>.<...>.<parameter> form, where components are separated by a dot.

Parameters
  • **params – Estimator parameters

  • self (etna.core.mixins.TMixin) –

  • params (dict) –

Returns

New instance with changed parameters

Return type

etna.core.mixins.TMixin

Examples

>>> from etna.pipeline import Pipeline
>>> from etna.models import NaiveModel
>>> from etna.transforms import AddConstTransform
>>> model = model=NaiveModel(lag=1)
>>> transforms = [AddConstTransform(in_column="target", value=1)]
>>> pipeline = Pipeline(model, transforms=transforms, horizon=3)
>>> pipeline.set_params(**{"model.lag": 3, "transforms.0.value": 2})
Pipeline(model = NaiveModel(lag = 3, ), transforms = [AddConstTransform(in_column = 'target', value = 2, inplace = True, out_column = None, )], horizon = 3, )
to_dict()

Collect all information about etna object in dict.

transform(df: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame[source]

Transform data from df with _OneSegmentSpecialDaysTransform and generate a column of special day flags.

Parameters

df (pd.DataFrame) – value series with index column in timestamp format

Returns

pd.DataFrame with ‘anomaly_weekday’, ‘anomaly_monthday’ or both of them columns no-timestamp indexed that contains 1 at i-th position if i-th day is a special day

Return type

pandas.core.frame.DataFrame