Skip to main content

GluonTS is a Python toolkit for probabilistic time series modeling, built around MXNet.

Project description

GluonTS - Probabilistic Time Series Modeling in Python

GluonTS is a Python toolkit for probabilistic time series modeling, built around MXNet.

GluonTS provides utilities for loading and iterating over time series datasets, state of the art models ready to be trained, and building blocks to define your own models and quickly experiment with different solutions.

Installation

GluonTS requires Python 3.6, and the easiest way to install it is via pip:

pip install gluonts

Contributing

If you wish to contribute to the project, please refer to our contribution guidelines.

Quick start guide

This simple example illustrates how to train a model from GluonTS 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.

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

The first 100 data points look like follows:

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

Data

We can now prepare a training dataset for our model to train on. Datasets in GluonTS 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 datapoint, and the "target" field containing time series data. For training, we will use data up to midnight on April 5th, 2015.

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

A forecasting model in GluonTS 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 freq="5min", and we will train a model to predict the next hour, so prediction_length=12. We also specify some minimal training options.

from gluonts.model.deepar import DeepAREstimator
from gluonts.trainer import Trainer

estimator = DeepAREstimator(freq="5min", prediction_length=12, trainer=Trainer(epochs=10))
predictor = estimator.train(training_data=training_data)

During training, useful information about the progress will be displayed. To get a full overview of the available options, please refer to the documentation 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"
)

from gluonts.dataset.util import to_pandas

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')

Forecast

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).

Further examples

The following are good entry-points to understand how to use many features of GluonTS:

The following modules illustrate how custom models can be implemented:

Project details


Release history Release notifications | RSS feed

This version

0.1.1

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gluonts-0.1.1.tar.gz (143.8 kB view details)

Uploaded Source

Built Distribution

gluonts-0.1.1-py3-none-any.whl (215.2 kB view details)

Uploaded Python 3

File details

Details for the file gluonts-0.1.1.tar.gz.

File metadata

  • Download URL: gluonts-0.1.1.tar.gz
  • Upload date:
  • Size: 143.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.1

File hashes

Hashes for gluonts-0.1.1.tar.gz
Algorithm Hash digest
SHA256 71021419f09076e98b746fe38b23e833d7aecf649ffac52b9f23f9aff07678a9
MD5 fd47f28f54351b2d12e8bbbd3aa22aaf
BLAKE2b-256 dc3c3565f0dc4c017e9dc9f4efe3bfe948ce79d15b9931b5a16968a15e9c2d4a

See more details on using hashes here.

File details

Details for the file gluonts-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: gluonts-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 215.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.6.1

File hashes

Hashes for gluonts-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c18a5628711cc5c7c9d73a3693c07230a86b64b3c18531514d8e6958f5ded861
MD5 62ac114617beb8b009d0cf0bd196d68d
BLAKE2b-256 1c097995513e3358e321ba10ead7426b3c6c2b7d00c487901e8c10a039cc3622

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page