_OneSegmentChangePointsSegmentationTransform¶
- class _OneSegmentChangePointsSegmentationTransform(in_column: str, out_column: str, change_points_model: etna.transforms.decomposition.change_points_based.change_points_models.base.BaseChangePointsModelAdapter)[source]¶
Bases:
etna.transforms.decomposition.change_points_based.base._OneSegmentChangePointsTransform
_OneSegmentChangePointsSegmentationTransform make label encoder to change points.
Init _OneSegmentChangePointsSegmentationTransform. :param in_column: name of column to apply transform to :param out_column: result column name. If not given use
self.__repr__()
:param change_points_model: model to get change points- Inherited-members
- Parameters
in_column (str) –
out_column (str) –
change_points_model (etna.transforms.decomposition.change_points_based.change_points_models.base.BaseChangePointsModelAdapter) –
Methods
fit
(df)Fit transform.
fit_transform
(df)Fit and transform Dataframe.
Split df to intervals of stable trend according to previous change point detection and add trend to each one.
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.
- fit(df: pandas.core.frame.DataFrame) etna.transforms.decomposition.change_points_based.base._OneSegmentChangePointsTransform ¶
Fit transform. Get no-changepoints intervals with change_points_model and fit per_interval_model on the intervals.
- Parameters
df (pandas.core.frame.DataFrame) – dataframe to process
- Returns
fitted _OneSegmentChangePointsTransform
- Return type
self
- 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 ¶
Split df to intervals of stable trend according to previous change point detection and add trend to each one.
- Parameters
df (pandas.core.frame.DataFrame) – one segment dataframe to turn trend back
- Returns
df – df with restored trend in in_column
- Return type
pd.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 aPipeline
.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 ¶
Transform data from df.
- Parameters
df (pandas.core.frame.DataFrame) – dataframe to apply transformation to
- Returns
dataframe with applied transformation
- Return type
transformed_df