Skip to content

[WIP] Binseg refactoring #998

Merged
merged 17 commits into from
Dec 26, 2022
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add `IrreversibleTransform`, `ReversibleTransform`, `IrreversiblePerSegmentWrapper`, `ReversiblePerSegmentWrapper` classes ([#884](https://github.com/tinkoff-ai/etna/pull/884))
-
### Changed
-
- All the `ChengePoints*Transform` structure: added per-interval models, added shortcuts for detrend and level transformations ([#998](https://github.com/tinkoff-ai/etna/pull/998))
-
- Base class for transforms now works with TSDataset ([835](https://github.com/tinkoff-ai/etna/pull/835))
- All the transforms now has `in_column` attribute ([#820](https://github.com/tinkoff-ai/etna/pull/820))
Expand Down
2 changes: 1 addition & 1 deletion etna/analysis/change_points_trend/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def find_change_points(
Dict[str, List[pd.Timestamp]]
dictionary with list of trend change points for each segment
"""
from etna.transforms.decomposition.base_change_points import RupturesChangePointsModel
from etna.transforms.decomposition.change_points_based import RupturesChangePointsModel

result: Dict[str, List[pd.Timestamp]] = {}
df = ts.to_pandas()
Expand Down
6 changes: 3 additions & 3 deletions etna/pipeline/assembling_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ def assemble_pipelines(
--------
>>> from etna.pipeline import assemble_pipelines
>>> from etna.models import LinearPerSegmentModel, NaiveModel
>>> from etna.transforms import TrendTransform, AddConstTransform, LagTransform
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What was wrong with TrendTransform here?

>>> from etna.transforms import DateFlagsTransform, AddConstTransform, LagTransform
>>> assemble_pipelines(models=LinearPerSegmentModel(), transforms=[LagTransform(in_column='target', lags=[1]), AddConstTransform(in_column='target', value=1)], horizons=[1,2,3])
[Pipeline(model = LinearPerSegmentModel(fit_intercept = True, ), transforms = [LagTransform(in_column = 'target', lags = [1], out_column = None, ), AddConstTransform(in_column = 'target', value = 1, inplace = True, out_column = None, )], horizon = 1, ),
Pipeline(model = LinearPerSegmentModel(fit_intercept = True, ), transforms = [LagTransform(in_column = 'target', lags = [1], out_column = None, ), AddConstTransform(in_column = 'target', value = 1, inplace = True, out_column = None, )], horizon = 2, ),
Pipeline(model = LinearPerSegmentModel(fit_intercept = True, ), transforms = [LagTransform(in_column = 'target', lags = [1], out_column = None, ), AddConstTransform(in_column = 'target', value = 1, inplace = True, out_column = None, )], horizon = 3, )]
>>> assemble_pipelines(models=[LinearPerSegmentModel(), NaiveModel()], transforms=[LagTransform(in_column='target', lags=[1]), [AddConstTransform(in_column='target', value=1), TrendTransform(in_column='target')]], horizons=[1,2])
>>> assemble_pipelines(models=[LinearPerSegmentModel(), NaiveModel()], transforms=[LagTransform(in_column='target', lags=[1]), [AddConstTransform(in_column='target', value=1), DateFlagsTransform()]], horizons=[1,2])
[Pipeline(model = LinearPerSegmentModel(fit_intercept = True, ), transforms = [LagTransform(in_column = 'target', lags = [1], out_column = None, ), AddConstTransform(in_column = 'target', value = 1, inplace = True, out_column = None, )], horizon = 1, ),
Pipeline(model = NaiveModel(lag = 1, ), transforms = [LagTransform(in_column = 'target', lags = [1], out_column = None, ), TrendTransform(in_column = 'target', out_column = None, detrend_model = LinearRegression(), model = 'ar', custom_cost = None, min_size = 2, jump = 1, n_bkps = 5, pen = None, epsilon = None, )], horizon = 2, )]
Pipeline(model = NaiveModel(lag = 1, ), transforms = [LagTransform(in_column = 'target', lags = [1], out_column = None, ), DateFlagsTransform(day_number_in_week = True, day_number_in_month = True, day_number_in_year = False, week_number_in_month = False, week_number_in_year = False, month_number_in_year = False, season_number = False, year_number = False, is_weekend = True, special_days_in_week = (), special_days_in_month = (), out_column = None, )], horizon = 2, )]
"""
n_models = len(models) if isinstance(models, Sequence) else 1
n_horizons = len(horizons) if isinstance(horizons, Sequence) else 1
Expand Down
5 changes: 4 additions & 1 deletion etna/transforms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
from etna.transforms.base import ReversiblePerSegmentWrapper
from etna.transforms.base import ReversibleTransform
from etna.transforms.base import Transform
from etna.transforms.decomposition import BinsegTrendTransform
from etna.transforms.decomposition import BaseChangePointsTransform
from etna.transforms.decomposition import ChangePointsLevelTransform
from etna.transforms.decomposition import ChangePointsSegmentationTransform
from etna.transforms.decomposition import ChangePointsTrendTransform
from etna.transforms.decomposition import IrreversibleChangePointsTransform
from etna.transforms.decomposition import LinearTrendTransform
from etna.transforms.decomposition import ReversibleChangePointsTransform
from etna.transforms.decomposition import STLTransform
from etna.transforms.decomposition import TheilSenTrendTransform
from etna.transforms.decomposition import TrendTransform
Expand Down
15 changes: 10 additions & 5 deletions etna/transforms/decomposition/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from etna.transforms.decomposition.base_change_points import RupturesChangePointsModel
from etna.transforms.decomposition.binseg import BinsegTrendTransform
from etna.transforms.decomposition.change_points_segmentation import ChangePointsSegmentationTransform
from etna.transforms.decomposition.change_points_trend import ChangePointsTrendTransform
from etna.transforms.decomposition.change_points_based import ChangePointsSegmentationTransform
from etna.transforms.decomposition.change_points_based import ChangePointsTrendTransform
from etna.transforms.decomposition.change_points_based import RupturesChangePointsModel
from etna.transforms.decomposition.change_points_based.base import BaseChangePointsTransform
from etna.transforms.decomposition.change_points_based.base import IrreversibleChangePointsTransform
from etna.transforms.decomposition.change_points_based.base import ReversibleChangePointsTransform
from etna.transforms.decomposition.change_points_based.change_points_models import BaseChangePointsModelAdapter
from etna.transforms.decomposition.change_points_based.change_points_models import RupturesChangePointsModel
from etna.transforms.decomposition.change_points_based.level import ChangePointsLevelTransform
from etna.transforms.decomposition.change_points_based.trend import TrendTransform
from etna.transforms.decomposition.detrend import LinearTrendTransform
from etna.transforms.decomposition.detrend import TheilSenTrendTransform
from etna.transforms.decomposition.stl import STLTransform
from etna.transforms.decomposition.trend import TrendTransform
108 changes: 0 additions & 108 deletions etna/transforms/decomposition/base_change_points.py

This file was deleted.

73 changes: 0 additions & 73 deletions etna/transforms/decomposition/binseg.py

This file was deleted.

9 changes: 9 additions & 0 deletions etna/transforms/decomposition/change_points_based/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from etna.transforms.decomposition.change_points_based.base import BaseChangePointsTransform
from etna.transforms.decomposition.change_points_based.change_points_models import BaseChangePointsModelAdapter
from etna.transforms.decomposition.change_points_based.change_points_models import RupturesChangePointsModel
from etna.transforms.decomposition.change_points_based.detrend import ChangePointsTrendTransform
from etna.transforms.decomposition.change_points_based.level import ChangePointsLevelTransform
from etna.transforms.decomposition.change_points_based.per_interval_models import PerIntervalModel
from etna.transforms.decomposition.change_points_based.per_interval_models import SklearnPreprocessingPerIntervalModel
from etna.transforms.decomposition.change_points_based.per_interval_models import SklearnRegressionPerIntervalModel
from etna.transforms.decomposition.change_points_based.segmentation import ChangePointsSegmentationTransform
Loading