Hi, i am a bit confused about the hist_exog and fu...
# neural-forecast
j
Hi, i am a bit confused about the hist_exog and futr_exog features. How can i use totally different future features, that my model has not seen during training? I hve never seen such a case. I am looking at this code block: horizon = 24 # day-ahead daily forecast models = [NHITS(h = horizon, input_size = 5*horizon, futr_exog_list = ['gen_forecast', 'week_day'], # <- Future exogenous variables hist_exog_list = ['system_load'], # <- Historical exogenous variables stat_exog_list = ['market_0', 'market_1'], # <- Static exogenous variables scaler_type = 'robust')] from here: https://nixtla.github.io/neuralforecast/examples/exogenous_variables.html
c
future exogenous = features available in the future at time of prediction ie if you have the gen forecast for tomorrow (often available in ISOs) you can make a forecast at the current hour for all of tomorrow, ie “day-ahead” forecast
j
first of all, i guess it is a capability of the neuralfc algorithms, which i need to read up on. but lets take the case where i only have 'normal' external regressors, so i dont make a difference between historic and future. i just have regressors with my time-series, e.g.: sales = f(price, marketing). now i want to train using also price and marketing, but when making forecasts i want to use the same regressors (with varying values probably). how would i feed this into the model? would the historic and future regressors be the same in this case?
also it seems that the Auto-versions of the algorithms cant handle exogenous regressors? does this mean the whole ts-cv-tuning is only working without regressors?
@Chris Gervais, to put it simple: i want to use regressors like in statsforecast, but using DL algorithms
@José Morales, can you tell me if this makes sense? I define total calls to be my exogenous features in the past and also for future forecasts. can i define it like this in my config using ts-vc? # Use your own config or AutoNHITS.default_config nhits_config = dict( learning_rate = tune.loguniform(1e-4, 1e-2), # loguniform samples over log-space, which is common for learning rates. max_steps = tune.randint(500, 2000), # Random integer between 500 and 2000. input_size = tune.choice([horizon*2, horizon*3]), # if horizon is a variable and you want to just multiply it. batch_size = tune.randint(1, 20), windows_batch_size = tune.randint(100, 500), n_pool_kernel_size = tune.choice([[2, 2, 2], [16, 8, 1]]), n_freq_downsample = tune.choice([[168, 24, 1], [24, 12, 1], [1, 1, 1]]), activation = 'ReLU', n_blocks = [1, 1, 1], mlp_units = [[512, 512], [512, 512], [512, 512]], interpolation_mode = "linear", val_check_steps = 100, hist_exog_list = ['total_calls'], futr_exog_list = ['total_calls'] ) horizon=6 model = [AutoNHITS(h=horizon, config=nhits_config, loss = MQLoss(), num_samples=15, # number of configurations explored --> ideally above 25, search_alg=HyperOptSearch()) # number of configurations explored --> ideally above 20!! ]
j
Yes. If you have those features both when training and at inference you have to provide them through
hist_exog_list
and
futr_exog_list
. For the Auto models they should be defined in the config as you're doing here. The point of being there is that allows you to also try including them or not in your trials
👍 2
c
and for the sake of clarity, if you have 'normal' regressors that you expect to be available for the full horizon, they would be classified as future regressors
👍 1
j
thanks so much for your answers! amazing
l
Hi @Chris Gervais, Can you elaborate on @jan rathfelder's question on why the features in futr_exog_list and hist_exog_list can be different? Shouldn't the features in historical df be the same as in the future df? How do the nfc models use features to forecast that they were not trained on?
futr_exog_list = ['gen_forecast', 'week_day'], # <- Future exogenous variables
hist_exog_list = ['system_load'], # <- Historical exogenous variables
stat_exog_list = ['market_0', 'market_1'], # <- Static exogenous variables
thanks.
c
just to be clear, nfc models are trained on both future and historical features. there isn’t a “mapping” between future and historical features, they’re entirely separate columns, with the difference being historical features only have data in the past where as future regressors have data in the future. in the example above, system load represents what the actual demand on the grid is at any given time. you can imagine in production this data not being available for future timestamps (ie the forecast horizon), but you can also imagine that data containing some helpful information about timestamps you do care about. NF and other newer libraries allow you to leverage both types of regressors. If it helps conceptually, I find it helpful to build a dataframe manually with both types of features by taking the historical features and taking lagged versions of them. Ie system load becomes system load at t-1, t-2 etc. so that for any t+1 timestamp youll notice you have all the data available to make the prediction. this is a simplified version (I think, @Nixtla Team please confirm) of what happens under the hood of NFC
j
Yes. If you have those features both when training and at inference you have to provide them through
hist_exog_list
and
futr_exog_list
.
Hey folks, just wanted to correct this statement. If you have a feature available both when training and at inference it should be specified only in
futr_exog_list
. As Chris points out they're entirely separate columns, the difference is that when passing the inputs to the model for the historic features we provide
input_size
samples and for the future features we provide
input_size + h
samples. So if you specify them in both you'll have the same information in a portion of the inputs, which will just be wasted computation.