linkedin / greykite

A flexible, intuitive and fast forecasting library
BSD 2-Clause "Simplified" License
1.81k stars 106 forks source link

Predicted values and metrics for N-step ahead forecast. #106

Closed ArcticSublime closed 1 year ago

ArcticSublime commented 1 year ago

Hi,

I am currently working on a task that uses daily data to forecast the next 7 days. My understanding is that the values of result.backtest.df_test["forecast"] and result.backtest.test_evaluation are based on one-step ahead forecasts. How can I get all the forecast values from one to seven days ahead at each point in the test period? Also, is it possible to use the N-step ahead forecast metrics instead of the one-step ahead forecast metrics in the grid search?

Thanks!

amyfei2015 commented 1 year ago

To forecast for next 7 days, you can specify the forecast_horizon to 7. The model shall then predict for next 7 days. Let us know if that helps, thanks! (The documentation is here)

ArcticSublime commented 1 year ago

Hi @amyfei2015, thank you for your reply! I've set forecast_horizon to 7, so I can get seven-day-ahead forecasts, but it seems to be only for the last day of the training/testing period. Is there a built-in method to get a seven-day-ahead forecast for each time point of the dataset? What I'd like to obtain is something like the red dots in Fig. 3(b) not Fig. 3(a) in the following figure.

image

amyfei2015 commented 1 year ago

Hi! The results from result.backtest will be predicted by the model trained from df_train (so it's also different from Fig. 3(a)), and this cannot be used to train multiple models to predict for each time point. Please checkout the benchmarking class here for your purpose.

One trick on running t+7d model to save speed is that if you only need to look at the forecast right on the 7th day but not the days before, you can set forecast_one_by_one in model_components_param to False.

Let us know if you have more questions on this, thanks!

amyfei2015 commented 1 year ago

Hi! Actually you can use the benchmarking class to get the results you want. Please check here! (Also edited my previous comment, sorry if that causes confusion!)

ArcticSublime commented 1 year ago

Hi @amyfei2015, the second half of the Compare forecasts in your link seems to be exactly the result I need.

Thank you so much!