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

Problem with statsforecast mstl_decomposition #857

Closed
Jonathan-87 opened this issue Jun 14, 2024 · 2 comments · Fixed by #861
Closed

Problem with statsforecast mstl_decomposition #857

Jonathan-87 opened this issue Jun 14, 2024 · 2 comments · Fixed by #861
Labels

Comments

@Jonathan-87
Copy link

What happened + What you expected to happen

When using mstl_decomposition if I'm passing a multiple frequencies like 7 and 365 for daily data then I'm getting an error saying "KeyError: "['seasonal'] not in index"" because when applying multiple frequencies the name of the resulting variables will be seasonal7 and seasonal365

Versions / Dependencies

statsforecast 1.7.5

Reproduction script

from statsforecast import StatsForecast
from statsforecast.feature_engineering import mstl_decomposition
from statsforecast.models import MSTL, AutoARIMA

df = pd.read_csv('https://datasets-nixtla.s3.amazonaws.com/air-passengers.csv', parse_dates=['ds'])

#Here i used 12 and 24 for season length just for demonstration
model = MSTL(season_length=[12, 24], trend_forecaster=AutoARIMA())
df_feat, df_fut = mstl_decomposition(df, model=model, freq="M", h=horizon)

Issue Severity

None

@jmoralez
Copy link
Member

jmoralez commented Jun 18, 2024

Hey @Jonathan-87, thanks for raising this. The current implementation leverages a function that adds up the seasonal components into one, so the easiest fix would be to always add up the seasonal components, however I realize that it may be better to have them as individual features. What would be the expected output for you? Generating a trend + one feature for each seasonal component or just trend + seasonal (where the seasonal is the sum of all components)?

@Jonathan-87
Copy link
Author

Hi @jmoralez I think it's better to have the different seasonnalities as individual features.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants