About
This repository provides model weights to run load forecasting models trained on ComStock datasets. The companion dataset repository is this. The model definitions are present in the models directory. The corresponding trained model weights are present in the weights directory. The corresponding model keyword arguments (as a function of a provided lookback and lookahead) can be imported from the file model_kwargs.py.
Note that lookback is denoted by L and lookahead by T in the weights directory. We provide weights for the following (L,T) pairs: (512,4), (512,48), and (512,96), and for HOMogenous and HETerogenous datasets.
Packages
Executing the code only requires numpy and torch (PyTorch) packages. You can either have them in your Python base installation, or use a conda environment.
Example
In order to see how to use the model definitions and load the weights into them, see example.py.
Technical Details for Running the Models
In input layout of the models are as follows:
The
forward()functions ofLSTM,LSTNet, andPatchTSTtake in two arguments:forward(input, future_time_idx). They are laid out as follows:inputis a tensor of shape(B,L,num_features)whereBis the batch size,Lis the lookback duration, andnum_featuresis 8 for our current application.future_time_idxis a tensor of shape(B,T,2)whereTis the lookahead and 2 is the number of time index features.- The time indices in
inputas well asfut_time_idxare both normalized. - The custom
torch.utils.data.Datasetclass for the train, val, and test sets can be generated by executing theget_data_and_generate_train_val_test_setsfunction in thecustom_dataset.pyfile in the companion dataset. - Non-time features are normalized. The mean and standard deviation of the companion dataset can be inferred by executing
example_dataset.pythere and looking atCase 1andCase 4. - The output shape is
(B,1)denoting the pointwise forecastTsteps into the future.
The
forward()functions ofTransformer,Autoformer,Informer, andTimesNettake in two arguments:forward(input, future_time_idx). They are laid out as follows:inputis a tensor of shape(B,L,num_features)whereBis the batch size,Lis the lookback duration, andnum_featuresis 8 for our current application.future_time_idxis a tensor of shape(B,T,2)whereTis the lookahead and 2 is the number of time index features.- The time indices in
inputas well asfut_time_idxare un-normalized to allow for embedding. - The custom
torch.utils.data.Datasetclass for the train, val, and test sets can be generated by executing theget_data_and_generate_train_val_test_setsfunction in thecustom_dataset.pyfile in the companion dataset. - Non-time features are normalized. The mean and standard deviation of the companion dataset can be inferred by executing
example_dataset.pythere and looking atCase 2andCase 5. - The output shape is
(B,1)denoting the pointwise forecastTsteps into the future.
The
forward()functions ofTimesFMtakes in one argument:forward(input). It is laid out as follows:inputis a tensor of shape(B,L)whereBis the batch size andLis the lookback duration. Since it is univariate, there is only one feature.- The sole feature is normalized. The mean and standard deviation of the companion dataset can be inferred by executing
example_dataset.pythere and looking atCase 3andCase 6. - The custom
torch.utils.data.Datasetclass for the train, val, and test sets can be generated by executing theget_data_and_generate_train_val_test_setsfunction in thecustom_dataset_univariate.pyfile in the companion dataset. - The output shape is
(B,T)denoting the rolling horizon forecastTsteps into the future.
Credits
Some model definitions have been adapted from the code provided in the TSLib Library.