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

fix ResampleWithDistributionTransform with holidays transform #82

Merged
merged 4 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Update `CONTRIBUTING.md` with scenarios of documentation updates and release instruction ([#77](https://github.com/etna-team/etna/pull/77))

### Fixed
-
- Fix `ResampleWithDistributionTransform` working with categorical columns ([#82](https://github.com/etna-team/etna/pull/82))
-
- Fix links from tinkoff-ai/etna to etna-team/etna ([#47](https://github.com/etna-team/etna/pull/47))
-
Expand Down
1 change: 1 addition & 0 deletions etna/transforms/missing_values/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
:
result dataframe
"""
df = df.apply(pd.to_numeric)

Check warning on line 99 in etna/transforms/missing_values/resample.py

View check run for this annotation

Codecov / codecov/patch

etna/transforms/missing_values/resample.py#L99

Added line #L99 was not covered by tests
egoriyaa marked this conversation as resolved.
Show resolved Hide resolved
df["fold"] = self._get_folds(df)
df = df.reset_index().merge(self.distribution, on="fold").set_index("timestamp").sort_index()
df[self.out_column] = df[self.in_column].ffill() * df["distribution"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import pytest

from etna.transforms.missing_values import ResampleWithDistributionTransform
from etna.metrics import MSE
from etna.models import NaiveModel
from etna.pipeline import Pipeline
from etna.transforms import HolidayTransform
from etna.transforms import ResampleWithDistributionTransform
from tests.test_transforms.utils import assert_transformation_equals_loaded_original


Expand Down Expand Up @@ -132,3 +136,16 @@ def test_get_regressors_info_not_fitted():
def test_params_to_tune():
transform = ResampleWithDistributionTransform(in_column="regressor_exog", distribution_column="target")
assert len(transform.params_to_tune()) == 0


def test_working_with_categorical_columns(example_tsds):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure that we need pipeline here, we just want to check that fit_transform works with categoricals. Try to be more minimalistic

model = NaiveModel()
holiday = HolidayTransform(out_column="holiday_regressor")
resample = ResampleWithDistributionTransform(distribution_column="target", in_column="holiday_regressor")
transforms = [holiday, resample]
pipeline = Pipeline(
model=model,
transforms=transforms,
horizon=2,
)
pipeline.backtest(ts=example_tsds, metrics=[MSE()], n_folds=2)