Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed ModelDecomposeTransform import #459

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
-
- Fixed `ModelDecomposeTransform` import without `prophet` module ([#459](https://github.com/etna-team/etna/pull/459))
d-a-bunin marked this conversation as resolved.
Show resolved Hide resolved
-
-
-
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
Loading