Skip to content

Commit

Permalink
Fixed ModelDecomposeTransform import (#459)
Browse files Browse the repository at this point in the history
* fixed model types

* updated changelog

* review comment
  • Loading branch information
brsnw250 authored Aug 28, 2024
1 parent e5cc8d6 commit abaa870
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-

### Fixed
-
- Fix `ModelDecomposeTransform` import without `prophet` module ([#459](https://github.com/etna-team/etna/pull/459))
-
-
-
Expand Down
15 changes: 13 additions & 2 deletions etna/transforms/decomposition/model_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,40 @@

import pandas as pd

from etna import SETTINGS
from etna.datasets import TSDataset
from etna.datasets.utils import determine_num_steps
from etna.models import BATSModel
from etna.models import DeadlineMovingAverageModel
from etna.models import HoltModel
from etna.models import HoltWintersModel
from etna.models import ProphetModel
from etna.models import SARIMAXModel
from etna.models import SeasonalMovingAverageModel
from etna.models import SimpleExpSmoothingModel
from etna.models import TBATSModel
from etna.models.base import ContextRequiredModelType
from etna.models.base import ModelType
from etna.transforms import IrreversibleTransform

_SUPPORTED_MODELS = Union[
HoltWintersModel, # full
ProphetModel, # full
HoltModel, # full
SimpleExpSmoothingModel, # full
SARIMAXModel, # full
DeadlineMovingAverageModel, # need to account context/prediction size
SeasonalMovingAverageModel, # need to account context/prediction size
BATSModel, # dynamic components, not reliable
TBATSModel, # dynamic components, not reliable
]

if SETTINGS.prophet_required:
from etna.models import ProphetModel

_SUPPORTED_MODELS = Union[ # type: ignore
_SUPPORTED_MODELS,
ProphetModel, # full
]


class ModelDecomposeTransform(IrreversibleTransform):
"""Transform that uses ETNA models to estimate series decomposition.
Expand Down
5 changes: 5 additions & 0 deletions tests/test_transforms/test_decomposition/test_model_based.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@
from etna.models import BATSModel
from etna.models import CatBoostPerSegmentModel
from etna.models import DeadlineMovingAverageModel
from etna.models import HoltModel
from etna.models import HoltWintersModel
from etna.models import ProphetModel
from etna.models import SARIMAXModel
from etna.models import SeasonalMovingAverageModel
from etna.models import SimpleExpSmoothingModel
from etna.models import TBATSModel
from etna.pipeline import Pipeline
from etna.transforms import IForestOutlierTransform
Expand Down Expand Up @@ -253,6 +255,9 @@ def test_pipeline_models(ts_name, in_column, decompose_model, forecast_model, re
"decompose_model",
(
HoltWintersModel(),
HoltModel(),
SimpleExpSmoothingModel(),
HoltWintersModel(trend="add", seasonal="add"),
ProphetModel(),
SARIMAXModel(),
DeadlineMovingAverageModel(),
Expand Down

0 comments on commit abaa870

Please sign in to comment.