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

[BUG] Discrepancies between Pipeline and AutoRegressivePipeline in handling a given ts after transforms #440

Open
1 task done
d-a-bunin opened this issue Jul 31, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@d-a-bunin
Copy link
Collaborator

🐛 Bug Report

There is a difference in a way how Pipeline and AutoRegressivePipeline are handling a given ts in forecast in relation to transforms.

  • AutoRegressivePipeline seems to take into account transforms which were already applied before calling forecast
  • Pipeline seems not to take into account transforms which were already applied before calling forecast

Expected behavior

I think that the behavior should be the same. It isn't really obvious which is better, but probably Pipeline's.

How To Reproduce

from copy import deepcopy

from etna.datasets import TSDataset
from etna.datasets import generate_ar_df
from etna.pipeline import AutoRegressivePipeline, Pipeline
from etna.transforms import LagTransform, AddConstTransform
from etna.models import LinearMultiSegmentModel


def main():
    df = generate_ar_df(n_segments=3, start_time="2020-01-01", periods=100, freq="D")
    ts = TSDataset(df=df, freq="D")
    
    model = LinearMultiSegmentModel()
    transforms = [
        LagTransform(in_column="target", lags=[7, 8, 9, 10])
    ]
    autoreg_pipeline = AutoRegressivePipeline(model=model, transforms=transforms, horizon=7)
    pipeline = Pipeline(model=model, transforms=transforms, horizon=7)

    additional_const_transform = AddConstTransform(in_column="target", value=10)
    ts.transform(transforms=[additional_const_transform])

    autoreg_pipeline.fit(deepcopy(ts))
    pipeline.fit(deepcopy(ts))

    autoreg_forecast = autoreg_pipeline.forecast()
    forecast = pipeline.forecast()
    
    mean_autoreg = autoreg_forecast.to_pandas(features=["target"]).mean().mean()
    mean = forecast.to_pandas(features=["target"]).mean().mean()

    assert abs(mean_autoreg - mean) < 5


if __name__ == "__main__":
    main()

Environment

No response

Additional context

No response

Checklist

  • Bug appears at the latest library version
@d-a-bunin d-a-bunin added the bug Something isn't working label Jul 31, 2024
@d-a-bunin d-a-bunin moved this from New to Specification in etna board Jul 31, 2024
@d-a-bunin d-a-bunin moved this from Specification to Todo in etna board Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

1 participant