Skip to content

Add logging to TSDataset.inverse_transform #642

Merged
merged 5 commits into from
Apr 12, 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 @@ -30,7 +30,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
-
-
- Add in_column to plot_anomalies, plot_anomalies_interactive ([#618](https://github.com/tinkoff-ai/etna/pull/618))
-
- Add logging to TSDataset.inverse_transform ([#642](https://github.com/tinkoff-ai/etna/pull/642))

### Fixed
- Passing non default params for default models STLTransform ([#641](https://github.com/tinkoff-ai/etna/pull/641))
Expand Down
1 change: 1 addition & 0 deletions etna/datasets/tsdataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ def inverse_transform(self):
"""
if self.transforms is not None:
for transform in reversed(self.transforms):
tslogger.log(f"Inverse transform {repr(transform)} is applied to dataset")
self.df = transform.inverse_transform(self.df)

@property
Expand Down
12 changes: 12 additions & 0 deletions tests/test_loggers/test_console_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,18 @@ def test_tsdataset_make_future_logging(example_tsds: TSDataset):
tslogger.remove(idx)


def test_tsdataset_inverse_transform_logging(example_tsds: TSDataset):
"""Check working of logging inside `TSDataset.inverse_transform`."""
transforms = [LagTransform(lags=5, in_column="target"), AddConstTransform(value=5, in_column="target")]
file = NamedTemporaryFile()
_logger.add(file.name)
example_tsds.fit_transform(transforms=transforms)
idx = tslogger.add(ConsoleLogger())
example_tsds.inverse_transform()
check_logged_transforms(log_file=file.name, transforms=transforms[::-1])
tslogger.remove(idx)


def test_backtest_logging(example_tsds: TSDataset):
"""Check working of logging inside backtest."""
file = NamedTemporaryFile()
Expand Down