etna icon indicating copy to clipboard operation
etna copied to clipboard

[BUG] Can't forecast first point with `CatBoostPerSegmentModel `

Open Mr-Geekman opened this issue 2 years ago • 0 comments

🐛 Bug Report

In some circumstances we can't predict first point with CatBoostPerSegmentModel.

Expected behavior

First point is predicted.

How To Reproduce

import pandas as pd

from etna.datasets import TSDataset
from etna.models import CatBoostPerSegmentModel
from etna.pipeline import Pipeline


def main():
    # load data
    timestamp = pd.date_range(start="2020-01-01", periods=3, freq="D")
    timestamp_exog = pd.date_range(start="2020-01-01", periods=6, freq="D")
    df = pd.DataFrame({"timestamp": timestamp, "segment": ["segment_0"] * 3, "target": [1, 2, 3]})
    df_exog = pd.DataFrame(
        {"timestamp": timestamp_exog, "segment": ["segment_0"] * 6, "regressor": [1, 2, 3, None, 5, 6]}
    )
    ts = TSDataset(df=TSDataset.to_dataset(df), df_exog=TSDataset.to_dataset(df_exog), freq="D", known_future="all")

    # fit pipeline
    model = CatBoostPerSegmentModel()
    pipeline = Pipeline(model=model, horizon=2)
    pipeline.fit(ts)

    # forecast
    ts_forecast = pipeline.forecast()
    assert ts_forecast.df.loc[:, pd.IndexSlice[:, "target"]].isna().any().any()


if __name__ == "__main__":
    main()

Environment

No response

Additional context

No response

Checklist

  • [X] Bug appears at the latest library version

Mr-Geekman avatar Jul 07 '22 14:07 Mr-Geekman