Skip to content

Fix native networks to work with generated future equals to horizon #936

Merged
merged 2 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all 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 @@ -25,7 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
-
-
-
- Fix native networks to work with generated future equals to horizon ([#936](https://github.com/tinkoff-ai/etna/pull/936))
-
-

Expand Down
2 changes: 1 addition & 1 deletion etna/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ def forecast(self, ts: "TSDataset", horizon: int) -> "TSDataset":
"""
test_dataset = ts.to_torch_dataset(
make_samples=functools.partial(
self.net.make_samples, encoder_length=self.encoder_length, decoder_length=self.decoder_length
self.net.make_samples, encoder_length=self.encoder_length, decoder_length=horizon
),
dropna=False,
)
Expand Down
2 changes: 1 addition & 1 deletion etna/pipeline/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def _forecast(self) -> TSDataset:
raise ValueError("Something went wrong, ts is None!")

if isinstance(self.model, DeepBaseModel):
future = self.ts.make_future(future_steps=self.model.decoder_length, tail_steps=self.model.encoder_length)
future = self.ts.make_future(future_steps=self.horizon, tail_steps=self.model.encoder_length)
predictions = self.model.forecast(ts=future, horizon=self.horizon)
else:
future = self.ts.make_future(self.horizon)
Expand Down
11 changes: 9 additions & 2 deletions tests/test_models/nn/test_mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,14 @@
from etna.transforms import StandardScalerTransform


@pytest.mark.parametrize("horizon", [8, 13])
@pytest.mark.parametrize(
"horizon",
[
8,
13,
15,
],
)
def test_mlp_model_run_weekly_overfit_with_scaler(ts_dataset_weekly_function_with_horizon, horizon):

ts_train, ts_test = ts_dataset_weekly_function_with_horizon(horizon)
Expand All @@ -31,7 +38,7 @@ def test_mlp_model_run_weekly_overfit_with_scaler(ts_dataset_weekly_function_wit
decoder_length=decoder_length,
trainer_params=dict(max_epochs=100),
)
future = ts_train.make_future(decoder_length)
future = ts_train.make_future(horizon)
model.fit(ts_train)
future = model.forecast(future, horizon=horizon)

Expand Down
11 changes: 9 additions & 2 deletions tests/test_models/nn/test_rnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@


@pytest.mark.long_2
@pytest.mark.parametrize("horizon", [8, 13])
@pytest.mark.parametrize(
"horizon",
[
8,
13,
15,
],
)
def test_rnn_model_run_weekly_overfit_with_scaler(ts_dataset_weekly_function_with_horizon, horizon):
"""
Given: I have dataframe with 2 segments with weekly seasonality with known future
Expand All @@ -28,7 +35,7 @@ def test_rnn_model_run_weekly_overfit_with_scaler(ts_dataset_weekly_function_wit
model = RNNModel(
input_size=1, encoder_length=encoder_length, decoder_length=decoder_length, trainer_params=dict(max_epochs=100)
)
future = ts_train.make_future(decoder_length, encoder_length)
future = ts_train.make_future(horizon, encoder_length)
model.fit(ts_train)
future = model.forecast(future, horizon=horizon)

Expand Down