_OneSegmentLinearTrendBaseTransform¶
- class _OneSegmentLinearTrendBaseTransform(in_column: str, regressor: sklearn.base.RegressorMixin, poly_degree: int = 1)[source]¶
Bases:
etna.transforms.base.OneSegmentTransform
Transform for one segment that implements trend subtraction and reconstruction feature.
Create instance of _OneSegmentLinearTrendBaseTransform.
- Parameters
in_column (str) – name of processed column
regressor (sklearn.base.RegressorMixin) – instance of sklearn :py:class`sklearn.base.RegressorMixin` to predict trend
poly_degree (int) – degree of polynomial to fit trend on
- Inherited-members
Methods
fit
(df)Fit regression detrend_model with data from df.
fit_transform
(df)Fit regression detrend_model with data from df and subtract the trend from df.
Inverse transformation for trend subtraction: add trend to prediction.
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: subtract linear trend found by regressor.
- fit(df: pandas.core.frame.DataFrame) etna.transforms.decomposition.detrend._OneSegmentLinearTrendBaseTransform [source]¶
Fit regression detrend_model with data from df.
- Parameters
df (pandas.core.frame.DataFrame) – data that regressor should be trained with
- Returns
instance with trained regressor
- Return type
- fit_transform(df: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame [source]¶
Fit regression detrend_model with data from df and subtract the trend from df.
- Parameters
df (pandas.core.frame.DataFrame) – data to train regressor and transform
- Returns
residue after trend subtraction
- Return type
pd.DataFrame
- inverse_transform(df: pandas.core.frame.DataFrame) pandas.core.frame.DataFrame [source]¶
Inverse transformation for trend subtraction: add trend to prediction.
- Parameters
df (pandas.core.frame.DataFrame) – data to transform
- Returns
data with reconstructed trend
- 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.