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

Manually set horizon weights to different windows #939

Open
Newaij0 opened this issue Mar 25, 2024 · 1 comment
Open

Manually set horizon weights to different windows #939

Newaij0 opened this issue Mar 25, 2024 · 1 comment

Comments

@Newaij0
Copy link

Newaij0 commented Mar 25, 2024

Description

To my understanding, currently the implementation of horizon weights is by adding a fixed horizon_weight list when initializing the loss function.

horizon_weight = np.hstack((np.ones(10,)*2, np.ones(10,), np.ones(10,)*2))
horizon = 30 

model1 = TFT(h = horizon, 
             input_size = horizon*3,
             hidden_size = 64, 
             n_head = 4,
             loss = MAE(horizon_weight = horizon_weight),  ##
             valid_loss = MAE(), # MAE()
             learning_rate = 0.001,
             dropout = 0.1,
             attn_dropout = 0.1,
             futr_exog_list = futr_exog,
             hist_exog_list = hist_exog,
             stat_exog_list = stat_exog,
             max_steps = 600,
             val_check_steps = 50,  
             scaler_type = 'robust',
             batch_size = 128)

However in the case I'm dealing with, the loss during holidays is considered more important, not the distance between predicted timestamp and current timestamp.

I add a column to the input DataFrame representing the weight of each timestamp and try to modify the base window class to extract weights for different time windows. Is there any way to adding weight more easily?

Thanks

Use case

Setting different horizon weight to each window by simply adding a weight column in the input DataFrame.

@elephaint
Copy link
Contributor

Thanks for the suggestion. While we consider it, options to account for different sample importances are:

  • Use a different loss function, e.g. MSE if holidays typically show higher target values. MSE will penalize errors on those higher values to a larger extent than MAE.
  • This is a bit iffy, but you can scale the target by the sample weights yourself and scale back with the correct weights for prediction when predicting a holiday or non-holiday. In that case, the forecasting task would be to forecast the importance-weighted time series rather than the actual time series.

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

No branches or pull requests

2 participants