Giter Site home page Giter Site logo

pratham16cse / aggforecaster Goto Github PK

View Code? Open in Web Editor NEW
18.0 4.0 4.0 91.53 MB

Code for "Coherent Probabilistic Aggregate Queries on Long-horizon Forecasts", IJCAI 2022

Home Page: https://arxiv.org/pdf/2111.03394v1.pdf

Python 99.13% Shell 0.87%
probabilistic-forecasting long-range-forecasting time-series-forecasting transformer-architecture transformer-models time-series

aggforecaster's Introduction

Coherent Probabilistic Aggregate Queries on Long-horizon Forecasts

This is the code produced as part of the paper Coherent Probabilistic Aggregate Queries on Long-horizon Forecasts

Coherent Probabilistic Aggregate Queries on Long-horizon Forecasts.

Prathamesh Deshpande and Sunita Sarawagi. IJCAI 2022. arXiv:2111.03394v1.

Package Dependencies / Requirements

  • Python 3.7.9 (recommended).
  • All the requirements are specified in requirements.txt.

Run

./script.sh

How to work with Command Line Arguments?

  • If an optional argument is not passed, it's value will be extracted from configuration specified in the file main.py (based on dataset_name, model_name).
  • If a valid argument value is passed through command line arguments, the code will use it further. That is, it will ignore the value assigned in the configuration.

Command Line Arguments Information

Argument name Type Valid Assignments Default
dataset_name str azure, ett, etthourly, Solar, taxi30min, Traffic911 positional argument
saved_models_dir str - None
output_dir str - None
N_input int >0 -1
N_output int >0 -1
epochs int >0 -1
normalize str same, zscore_per_series, gaussian_copula, log None
learning_rate float >0 -1.0
hidden_size int >0 -1
num_grulstm_layers int >0 -1
batch_size int >0 -1
v_dim int >0 -1
t2v_type str local, idx, mdh_lincomb, mdh_parti None
K_list [int,...,int ] [>0,...,>0 ] []
device str - None

Datasets

All the datasets can be found here.

Add the dataset files/directories in data directory before running the code.

Output files

Targets and Forecasts

Following output files are stored in the <output_dir>/<dataset_name>/ directory.

File name Description
inputs.npy Test input values, size: number of time-series x N_input
targets.npy Test target/ground-truth values, size: number of time-series x N_output
<model_name>_pred_mu.npy Mean forecast values. The size of the matrix is number of time-series x number of time-steps
<model_name>_pred_std.npy Standard-deviation of forecast values. The size of the matrix is number of time-series x number of time-steps

Metrics

All the evaluation metrics on test data are stored in <output_dir>/results_<dataset_name>.json in the following format:

{
  <model_name1>: 
    {
      'crps':<crps>,
      'mae':<mae>,
      'mse':<mse>,
      'smape':<smape>,
      'dtw':<dtw>,
      'tdi':<tdi>,
    }
  <model_name2>: 
    {
      'crps':<crps>,
      'mae':<mae>,
      'mse':<mse>,
      'smape':<smape>,
      'dtw':<dtw>,
      'tdi':<tdi>,
    }
    .
    .
    .
}

Here <model_name1>, <model_name2>, ... are different models under consideration.

aggforecaster's People

Contributors

pratham16 avatar pratham16cse avatar vincent-leguen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

aggforecaster's Issues

TODOS

  • Plotting parameter
  • json parser
  • Re-structure main file, and others if needed
  • save epoch to resume the training
  • Add 911 and taxi datasets, but only in the context of counts
  • Features??

Taxi data possibilities

  1. Consider all zones irrespective of number of pickups -- If a zone does not have a pickup in an hour, the value will be zero
  2. Consider only zones that have at least one pickup per hour
  3. Only consider top k zones according to number of pickups over the duration
  • If required, get data for more months as well

Forecast method

As per my under standing of your paper ('Long Range Probabilistic Forecasting in Time-Series using High Order Statistics'), you are taking multiple (2) averages of the original series and then the informer model is being trained independently on these averages and the original series as well. I have a couple of questions here.

  1. How many informer models are being trained?...i.e if we have 3 time series (2 aggregate and 1 original) does 1 informer model get trained on these 3 time series independently or does each time series get its own informer model ?

  2. Once the model trained, a new multivariate gaussian is being defined with mean and covariance. How exactly is this mean being calculated ?

Train base model in teacher-forcing mode

  • The model makes sequential predictions during training also.
  • This might be the reason for poor performance of DILATE and MSE on Taxi dataset as forecast horizon at the bottom level is sufficiently large.
  • Add teacher-forcing mode of training in order to better learn the parameters of the base model at bottom level.

Parser for Datasets of Gaussian Copula Paper

  • In both train.json and test.json, each line is a time-series.
  • In test.json, each series can be treated as an independent sequence.
  • Context length needs to be limited for both train and test.
  • For wiki, find out why initial ~9000 train and test sequences overlap.
  • For selecting only 2000 sequences for wiki, how to ensure same 2000 sequences get selected from both train and test?
  • Create this pre-processing for Solar, Wiki, and Exchange-rate.

Normalization

  • Try normalization only at bottom level
  • Find out how to handle normalization across levels

Learning Rate Tuning

  • Fix a basic learning rate tuning method that can be applied across all base models
  • Can try learning rate schedule also?

Use K as a hyper-parameter

  • Understand how to perform hyper-parameter turning in pytorch.
  • Get multiple solutions using multiple values of K.
  • Select the K that performs best on validation data.

Need better way to set stride while creating batches for training

Possible options:

  • Manually set stride for each dataset such that the model can see maximum possible patterns of input-output sequences in the training data.
  • Add stochasticity in the stride. For example, if stride is s, shift the window by U(s-r,s+r) where r is width for stochasticity

Errors running script.sh

This project looks exciting, but Im having trouble running the project. I don't see a requirements.txt or environment.yml, so I did my best to create one.

It looks like there might be some missing files from the project too:

in base_model.py

from models import transformer_manual_attn, transformer_dual_attn
ImportError: cannot import name 'transformer_manual_attn' from 'models' (unknown location)

Thanks for the help

Least Square Aggregation

  • Create first level of aggregation
  • Model and overall code should support multiple values in the time-series
  • Create new inference model for least square based aggregation
  • Write optimizer for least square consistency during inference
  • Modify real dataset processing such that each sequence is 3 dimensional at level 1
  • Multiple aggregation support in the main.py file (sum, leastsquare)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.