original example freq = 1 season_length = 24 horizon = 2 * seasonlength valid =…
Jump to turn (17)
- 1original example freq = 1 seasonlength = 24 horizon = 2 seasonlength valid = df.
- 2okay let's go thru each line of code, is this one correct valid = ycl4.groupby('
- 3look at the ouput for valid again, this is another way valid = ycl4.groupby('uni
- 4--------------------------------------------------------------------------- Shap
- 5how about the next function train = ycl4.join(valid, on=['uniqueid', 'y'], how='
- 6okay based on the expected output from the example uniqueid ds y trend seasonal
- 7I used your train code train = ycl4.join(valid, on=['uniqueid', 'ds'], how='anti
- 8from statsforecast.models import MSTL from statsforecast.featureengineering impo
- 9still same error, nothing has changed, same error as this original code from sta
- 10okay hold on, I understand why now, the code is working as intended, the data is
- 11cant we just make it easier by using the original code from statsforecast.models
- 12this is not for forecast, only to get the seasonal column to feed into arima, et
- 13from statsforecast.models import MSTL from statsforecast.featureengineering impo
- 14i either get error fitted or tiny dataset, which horizon and seasonlength should
- 15is there a way to set all the series below min length to have 0 seasonality to f
- 16is this correct order from statsforecast.models import MSTL from statsforecast.f
- 17hold on, this one should have 4 columns 'y' as well fullseasonaldata = ( pl.conc
- User
original example freq = 1 season_length = 24 horizon = 2 * season_length valid = df.groupby('unique_id').tail(horizon) train = df.drop(valid.index) model = MSTL(season_length=24) transformed_df, X_df = mstl_decomposition(train, model=model, freq=freq, h=horizon) expected output unique_id ds y trend seasonal 0 H1 1 605.0 501.350550 124.683643 1 H1 2 586.0 506.424549 87.115039 2 H1 3 586.0 511.453736 79.479564 this is my code converted to polars from statsforecast.models import MSTL from statsforecast.feature_engineering import mstl_decomposition
freq = '1w' season_length = 52 horizon = 2 * season_length valid = y_cl4.groupby('unique_id').tail(horizon) train = y_cl4.join(valid, on=['unique_id', 'y'], how='anti') model = MSTL(season_length=season_length) transformed_df, X_df = mstl_decomposition(train, model=model, freq=freq, h=horizon) output for valid unique_id ds y str datetime[μs] f64 "12420971_US01_… 2023-08-07 00:00:00 5.0 "12513482_US01_… 2022-07-18 00:00:00 132.0 "12513482_US01_… 2022-08-01 00:00:00 264.0 error 8 train = y_cl4.join(valid, on=['unique_id', 'y'], how='anti') 9 model = MSTL(season_length=season_length) ---> 10 transformed_df, X_df = mstl_decomposition(train, model=model, freq=freq, h=horizon) ValueError: number sections must be larger than 0.