TrendTransform¶
- class TrendTransform(in_column: str, change_points_model: Optional[etna.transforms.decomposition.change_points_based.change_points_models.base.BaseChangePointsModelAdapter] = None, per_interval_model: Optional[etna.transforms.decomposition.change_points_based.per_interval_models.base.PerIntervalModel] = None, out_column: Optional[str] = None)[source]¶
Bases:
etna.transforms.decomposition.change_points_based.base.IrreversibleChangePointsTransform
Transform that adds trend as a feature.
Transform divides each segment into intervals using
change_points_model
. Then a separate model is fitted on each interval usingper_interval_model
. New column is created with values predicted by the model of each interval.Evaluated function can be linear, mean, median, etc. Look at the signature to find out which models can be used.
Warning
This transform can suffer from look-ahead bias. For transforming data at some timestamp it uses information from the whole train part.
Init TrendTransform.
- Parameters
in_column (str) – name of column to apply transform to
change_points_model (Optional[etna.transforms.decomposition.change_points_based.change_points_models.base.BaseChangePointsModelAdapter]) – model to get trend change points, by default
ruptures.detection.Binseg
in a wrapper withn_bkps=5
is usedper_interval_model (Optional[etna.transforms.decomposition.change_points_based.per_interval_models.base.PerIntervalModel]) – model to process intervals of segment, by default
sklearn.linear_models.LinearRegression
in a wrapper is usedout_column (Optional[str]) – name of added column. If not given, use
self.__repr__()
- 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.
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.
Attributes
out_column
- params_to_tune() Dict[str, etna.distributions.distributions.BaseDistribution] [source]¶
Get default grid for tuning hyperparameters.
If
self.change_points_model
is equal to default then this grid tunes parameters:change_points_model.change_points_model.model
,change_points_model.n_bkps
. Other parameters are expected to be set by the user.- Returns
Grid to tune.
- Return type
Dict[str, etna.distributions.distributions.BaseDistribution]