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

[MFLES] Seasonality prediction incorrect when forecasting multi-seasonal time series beyond one period #938

Open
tehunter opened this issue Nov 14, 2024 · 0 comments
Labels

Comments

@tehunter
Copy link

What happened + What you expected to happen

If you have a time series with multiple seasonality periods, MFLES currently constructs the combined seasonality pattern in an array sized to the largest of the seasonality periods. This leads to an incomplete combined pattern being stored (unless the largest seasonality period happens to be a multiple of all the smaller periods).

For example, in the following example, the data has seasonal periods of 2 and 5. 10 days are needed to correctly capture the combined seasonality, but the forecast uses only a 5-day pattern.

image

I believe it's inconsequential if the forecast horizon is less than a full seasonality period.

Versions / Dependencies

Bug exists in main branch

Reproducible example

from statsforecast import StatsForecast
from statsforecast.models import (
    MFLES
)
import pandas as pd
import numpy as np

season_1 = np.array([0, 100])
season_2 = np.array([0, -200, 0, 0, 0])
dates = pd.date_range("2024-01-01", "2024-01-30")
n = len(dates)

sample_ts = pd.DataFrame({
    "ds": dates,
    "y": np.resize(season_1, n) + np.resize(season_2, n),
    "unique_id": "1"
})

model = MFLES(
    season_length=[2, 5],
    trend_lr=0,
    residuals_lr=0,
)
sf = StatsForecast(
    models=[model],
    freq="D"
)
sf.fit(
    sample_ts
)

forecast_df = sf.predict(h=30)
sf.plot(sample_ts, forecast_df)

Issue Severity

Medium: It is a significant difficulty but I can work around it.

@tehunter tehunter added the bug label Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant