DTS - Deep Time-Series Forecasting

DTS is a Keras library that provides multiple deep architectures aimed at multi-step time-series forecasting.

The Sacred library is used to keep track of different experiments and allow their reproducibility.

Installation

DTS is compatible with Python 3.5+, and is tested on Ubuntu 16.04.

The setup.py script of DTS will not attempt to install Sacred, Keras and a backend for it. Thus, before installing DTS, you have to manually install:

This choice has been taken in order to avoid any possible problem for the user. If you are already a Keras/Tesorflow user mind that if your version of Tensorflow is greater or equal to 1.14.0 then you need to check out this issue to install sacred correctly.

I have tested dts with the following dependencies:

ENV 1 ENV 2
numpy==1.14.2 numpy==1.17.0
tensorflow==1.12.0 tensorflow==1.14.0
keras==2.1.6 keras==2.2.4
sacred==0.7.4 sacred==0.7.5

To install dts from source:

git clone https://github.com/albertogaspar/dts.git
cd dts
pip install -e .

What's in it & How to use

Time-Series Forecasting

The package includes several deep learning architectures that can be used for multi step-time series forecasting. The package provides also several utilities to cast the forecasting problem into a supervised machine learning problem. Specifically a sliding window approach is used: each model is given a time window of size nT and asked to output a prediction for the following nO timesteps (see Figure below).

Run Experiment

python FILENAME.py --add_config FULLPATH_TO_YAML_FILE 

or:

python FILENAME.py --add_config FULLPATH_TO_YAML_FILE --grid_search 

_gridsearch: defines whether or not you are searching for the best hyperparamters. If True, multiple experiments are run, each with a different combination of hyperparamters. The process terminates when all possible combinations of hyperparamers have been explored.

_addconfig: The experiment's hyperparamters should be defined as a yaml file in the config folder (see How to write a config file for more details). FULLPATH_TO_YAML_FILE is the fullpath to the .yaml file that stores your configuration. The main function for your model should always look similar to this one:

observer: all the important information in an experiment can be stored either in MongoDB (default choice) or in multiple files (txt and json) inside a given folder (dts/logs/sacred/). Mongo Observer which stores all information in a MongoDB If you want to use the file-based logger then launch the script with the additional argument --observer file (once again, the default choice is --observer mongodb)

If you want to train a model using pretrained weights just run the model providing the paramter --load followed by the fullpath to the file containing the weights.

python FILENAME.py --add_config FULLPATH_TO_YAML_FILE --load FULLPATH_TO_WEIGHTS 

The model will be initilized with this weights before training.

Datasets

With DTS you can model your input values in many diffrent ways and then feed them to your favourite deep learning architectures. E.g.:

See how to format your data or check out the examples in dts.examples to know more about data formatting and the possibilities offered by DTS.

Available architectures

Included architectures are:

Project Structure & TODO list

Sacred Collected Information

The animation below provides an intuitive explanation of the information collected by Sacred (using MongoDB as Observer). The example refers to a completed experiment of a TCN model trained on the Individual household electric power consumption Data Set (for brevity, 'uci'):

When MongoDB is used as an Observer, the collected information for an experiment is stored in a document. In the above documents are visualized using MongoDB Compass

Reference

This is the code used for the Deep Learning for Time Series Forecasting: The Electric Load Case paper. Mind that the code has been changed a bit, thus you may notice some differences with the models described in the paper. If you encounter any problem or have any doubt don't hesitate to contact me.

If you find it interesting it please consider citing us:

@article{gasparin2019deep,
  title={Deep Learning for Time Series Forecasting: The Electric Load Case},
  author={Gasparin, Alberto and Lukovic, Slobodan and Alippi, Cesare},
  journal={arXiv preprint arXiv:1907.09207},
  year={2019}
}