Open ramdhan1989 opened 3 years ago
Hi @ramdhan1989 can you reproduce an example for the case when the prediction is flat?
Hi @mavillan , I only have one series and holiday information. I try model below : `model_kwargs = { "model_params": { "objective":"regression", 'metric':'rmse', 'num_leaves': 210-1, 'min_data_in_leaf': 210-1, 'learning_rate': 0.05, 'feature_fraction':0.8, 'bagging_fraction':0.8, 'bagging_freq':1, 'lambda_l2':0.1, 'boost_from_average': False, }, "time_features": [ "month", "month_progress", "year_week_cos", "year_week_sin", "month_cos", "month_sin", "week_day_cos", "week_day_sin", "month_day", "week_day" ], "window_functions":{ "mean": (None, [1,], [7,14,21,28]), "median": (None, [1,], [7,14,21,28]), "max": (None, [1,], [7,14,21,28]), "min": (None, [1,], [7,14,21,28]),}, "categorical_features": { "ts_uid": "default",}, "ts_uid_columns": ["ts_uid", ], }
model = LightGBMForecaster(**model_kwargs) model.fit(train_data=X)`
link to the data [https://drive.google.com/file/d/1TFf7F4FqGRYNPGJGNXzzgo3kvGDZoBrd/view?usp=sharing]
the forecast for 31 days ahead is flat (same number). is there anything wrong ? would you mind explaining window functions parameters for example this (I took from your code m5 solution) --> "mean": (None, [1,], [7,14,21,28]), what does it mean ? and then where should I put information about holiday and example code of it would be good. thank you
When using lag/rw features, you should make the predict like this: model.predict(X_test, recursive=True), i.e., you should activate the recursive flag such that the model performs one-step-ahead predictions. I think this is the reason for your flat predictions.
Here is the explanation for the window functions definition:
"mean": (None, [1,], [7,14,21,28])
will compute the rolling mean, shifted in one day, and window sizes of 7, 14, 21, 28. This will add a total of 4 new features: mean_shift1_window7, mean_shift1_window14, mean_shift1_window21, and mean_shift1_window28. Here is another example:
"mean": (None, [1, 28], [28,])
will compute the rolling mean, shifted in one and 28 days, and with window size of 28. This will add a total of 2 new features: mean_shift1_window28 and mean_shift28_window28.
Further, you can define how to compute the window function:
"custom_mean": (lambda x: np.mean(x), [1, 28], [28,])
does the same as the previous example. If the key of the dict is a name in: https://pandas.pydata.org/pandas-docs/stable/reference/window.html it is not necessary to define the function, instead let it to None.
Hi @mavillan thanks a lot for your explanation. I am still got flat prediction after adding recursive=True. any thought ? how about adding hoilday information ? there is "calendar_anomaly" option, is it something that can be used for this purpose ?
I am using my own data. any idea why the prediction is flat ? I try to forecast 30 days ahead