All Projects → zalandoresearch → Pytorch Ts

zalandoresearch / Pytorch Ts

Licence: other
PyTorch based Probabilistic Time Series forecasting framework based on GluonTS backend

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pytorch Ts

plotly-resampler
Visualize large time-series data in plotly
Stars: ✭ 200 (-39.39%)
Mutual labels:  time-series
Anomalize
Tidy anomaly detection
Stars: ✭ 263 (-20.3%)
Mutual labels:  time-series
Pycaret
An open-source, low-code machine learning library in Python
Stars: ✭ 4,594 (+1292.12%)
Mutual labels:  time-series
luftdatenpumpe
Process live and historical data from luftdaten.info, IRCELINE and OpenAQ. Filter by station-id, sensor-id and sensor-type, apply reverse geocoding, store into timeseries and RDBMS databases, publish to MQTT, output as JSON or visualize in Grafana.
Stars: ✭ 22 (-93.33%)
Mutual labels:  time-series
Time Series Machine Learning
Machine learning models for time series analysis
Stars: ✭ 261 (-20.91%)
Mutual labels:  time-series
Time Series Deep Learning State Of The Art
Scientific time series and deep learning state of the art
Stars: ✭ 277 (-16.06%)
Mutual labels:  time-series
Synthetic-data-gen
Various methods for generating synthetic data for data science and ML
Stars: ✭ 57 (-82.73%)
Mutual labels:  time-series
Luminaire
Luminaire is a python package that provides ML driven solutions for monitoring time series data.
Stars: ✭ 316 (-4.24%)
Mutual labels:  time-series
Timelines Chart
Timelines Chart
Stars: ✭ 259 (-21.52%)
Mutual labels:  time-series
Nightingale
💡 A Distributed and High-Performance Monitoring System. Prometheus enterprise edition
Stars: ✭ 4,003 (+1113.03%)
Mutual labels:  time-series
Merlion
Merlion: A Machine Learning Framework for Time Series Intelligence
Stars: ✭ 2,368 (+617.58%)
Mutual labels:  time-series
Chronix.server
The Chronix Server implementation that is based on Apache Solr.
Stars: ✭ 258 (-21.82%)
Mutual labels:  time-series
Pyaf
PyAF is an Open Source Python library for Automatic Time Series Forecasting built on top of popular pydata modules.
Stars: ✭ 289 (-12.42%)
Mutual labels:  time-series
tsfeatures
Calculates various features from time series data. Python implementation of the R package tsfeatures.
Stars: ✭ 87 (-73.64%)
Mutual labels:  time-series
Soft Dtw
Python implementation of soft-DTW.
Stars: ✭ 300 (-9.09%)
Mutual labels:  time-series
webgl-3d-animation
An interactive 3D animation using WebGL to depict a 2D predator prey ecology on a grid real-time mapped onto the surface of a 3D torus. Sound file is parsed then visualized both in time and frequency domains as well as rendered using Web Audio API - this is an exercise where I taught myself how to display data for an ongoing project on sound syn…
Stars: ✭ 23 (-93.03%)
Mutual labels:  time-series
Questdb
An open source SQL database designed to process time series data, faster
Stars: ✭ 7,544 (+2186.06%)
Mutual labels:  time-series
Stock Trading Ml
A stock trading bot that uses machine learning to make price predictions.
Stars: ✭ 325 (-1.52%)
Mutual labels:  time-series
Chartjs Plugin Streaming
Chart.js plugin for live streaming data
Stars: ✭ 310 (-6.06%)
Mutual labels:  time-series
Crate
CrateDB is a distributed SQL database that makes it simple to store and analyze massive amounts of data in real-time.
Stars: ✭ 3,254 (+886.06%)
Mutual labels:  time-series

PyTorchTS

PyTorchTS is a PyTorch Probabilistic Time Series forecasting framework which provides state of the art PyTorch time series models by utilizing GluonTS as its back-end API and for loading, transforming and back-testing time series data sets.

Installation

$ pip3 install pytorchts

Quick start

Here we highlight the the API changes via the GluonTS README.

import matplotlib.pyplot as plt
import pandas as pd
import torch

from gluonts.dataset.common import ListDataset
from gluonts.dataset.util import to_pandas

from pts.model.deepar import DeepAREstimator
from pts import Trainer

This simple example illustrates how to train a model on some data, and then use it to make predictions. As a first step, we need to collect some data: in this example we will use the volume of tweets mentioning the AMZN ticker symbol.

url = "https://raw.githubusercontent.com/numenta/NAB/master/data/realTweets/Twitter_volume_AMZN.csv"
df = pd.read_csv(url, header=0, index_col=0, parse_dates=True)

The first 100 data points look like follows:

df[:100].plot(linewidth=2)
plt.grid(which='both')
plt.show()

png

We can now prepare a training dataset for our model to train on. Datasets are essentially iterable collections of dictionaries: each dictionary represents a time series with possibly associated features. For this example, we only have one entry, specified by the "start" field which is the timestamp of the first data point, and the "target" field containing time series data. For training, we will use data up to midnight on April 5th, 2015.

training_data = ListDataset(
    [{"start": df.index[0], "target": df.value[:"2015-04-05 00:00:00"]}],
    freq = "5min"
)

A forecasting model is a predictor object. One way of obtaining predictors is by training a correspondent estimator. Instantiating an estimator requires specifying the frequency of the time series that it will handle, as well as the number of time steps to predict. In our example we're using 5 minutes data, so req="5min", and we will train a model to predict the next hour, so prediction_length=12. The input to the model will be a vector of size input_size=43 at each time point. We also specify some minimal training options in particular training on a device for epoch=10.

device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

estimator = DeepAREstimator(freq="5min",
                            prediction_length=12,
                            input_size=43,
                            trainer=Trainer(epochs=10,
                                            device=device))
predictor = estimator.train(training_data=training_data, num_workers=4)
    45it [00:01, 37.60it/s, avg_epoch_loss=4.64, epoch=0]
    48it [00:01, 39.56it/s, avg_epoch_loss=4.2, epoch=1] 
    45it [00:01, 38.11it/s, avg_epoch_loss=4.1, epoch=2] 
    43it [00:01, 36.29it/s, avg_epoch_loss=4.05, epoch=3]
    44it [00:01, 35.98it/s, avg_epoch_loss=4.03, epoch=4]
    48it [00:01, 39.48it/s, avg_epoch_loss=4.01, epoch=5]
    48it [00:01, 38.65it/s, avg_epoch_loss=4, epoch=6]   
    46it [00:01, 37.12it/s, avg_epoch_loss=3.99, epoch=7]
    48it [00:01, 38.86it/s, avg_epoch_loss=3.98, epoch=8]
    48it [00:01, 39.49it/s, avg_epoch_loss=3.97, epoch=9]

During training, useful information about the progress will be displayed. To get a full overview of the available options, please refer to the source code of DeepAREstimator (or other estimators) and Trainer.

We're now ready to make predictions: we will forecast the hour following the midnight on April 15th, 2015.

test_data = ListDataset(
    [{"start": df.index[0], "target": df.value[:"2015-04-15 00:00:00"]}],
    freq = "5min"
)
for test_entry, forecast in zip(test_data, predictor.predict(test_data)):
    to_pandas(test_entry)[-60:].plot(linewidth=2)
    forecast.plot(color='g', prediction_intervals=[50.0, 90.0])
plt.grid(which='both')

png

Note that the forecast is displayed in terms of a probability distribution: the shaded areas represent the 50% and 90% prediction intervals, respectively, centered around the median (dark green line).

Development

pip install -e .
pytest test

Citing

To cite this repository:

@software{pytorchgithub,
    author = {Kashif Rasul},
    title = {{P}yTorch{TS}},
    url = {https://github.com/zalandoresearch/pytorch-ts},
    version = {0.3.x},
    year = {2021},
}

Scientific Article

We have implemented the following model using this framework:

@INPROCEEDINGS{rasul2020tempflow,
  author = {Kashif Rasul and  Abdul-Saboor Sheikh and  Ingmar Schuster and Urs Bergmann and Roland Vollgraf},
  title = {{M}ultivariate {P}robabilistic {T}ime {S}eries {F}orecasting via {C}onditioned {N}ormalizing {F}lows},
  year = {2021},
  url = {https://openreview.net/forum?id=WiGQBFuVRv},
  booktitle = {International Conference on Learning Representations 2021},
}
@article{rasul2021timegrad,
    Author = {Kashif Rasul and Calvin Seward and  Ingmar Schuster and Roland Vollgraf}
    Title = {{A}utoregressive {D}enoising {D}iffusion {M}odels for {M}ultivariate {P}robabilistic {T}ime {S}eries {F}orecasting},
    Year = {2021},
    archivePrefix = {arXiv},
    eprint = {2101.12072},
    url = {https://arxiv.org/abs/2101.12072},
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].