Skip to content

[BUG] SARIMAX can't predict interval if horizon=1 #583

Closed
1 task done
Mr-Geekman opened this issue Mar 5, 2022 · 0 comments · Fixed by #637
Closed
1 task done

[BUG] SARIMAX can't predict interval if horizon=1 #583

Mr-Geekman opened this issue Mar 5, 2022 · 0 comments · Fixed by #637
Assignees
Labels
bug Something isn't working

Comments

@Mr-Geekman
Copy link
Contributor

🐛 Bug Report

SARIMAX can't predict interval if horizon=1, it fails with an error:

AttributeError: 'int' object has no attribute 'startswith'

The problem is inside _SARIMAXAdapter.predict. If horizon=1, then returned forecast after casting to pd.DataFrame hasn't "predicted_mean" column.

Expected behavior

No error.

How To Reproduce

import pandas as pd

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

HORIZON = 7


def main():
    df = pd.read_csv("examples/data/example_dataset.csv", parse_dates=["timestamp"])
    ts = TSDataset(df=TSDataset.to_dataset(df), freq="D")
    train_ts, test_ts = ts.train_test_split(test_size=HORIZON)

    # sarimax
    sarimax_pipeline = Pipeline(model=SARIMAXModel(), quantiles=[0.025, 0.1, 0.4, 0.9, 0.975], horizon=1)
    sarimax_pipeline.fit(ts=train_ts)
    forecast_sarimax = sarimax_pipeline.forecast(prediction_interval=True)

if __name__ == "__main__":
    main()

Environment

No response

Additional context

No response

Checklist

  • Bug appears at the latest library version
@Mr-Geekman Mr-Geekman added the bug Something isn't working label Mar 5, 2022
@Ama16 Ama16 self-assigned this Apr 7, 2022
@Ama16 Ama16 mentioned this issue Apr 7, 2022
9 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants