Need help with deepar?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

arrigonialberto86
213 Stars 74 Forks MIT License 33 Commits 6 Opened issues

Description

Tensorflow implementation of Amazon DeepAR

Services available

!
?

Need anything else?

Contributors list

# 429,607
scikit-...
streami...
HTML
C++
10 commits

deepar

Build Status

Tensorflow implementation of Amazon DeepAR

Example usage:

Fit a univariate time series: ```python %load_ext autoreload %autoreload 2

from tensorflow.python.framework.ops import disableeagerexecution disableeagerexecution()

from deepar.dataset.time_series import MockTs from deepar.model.lstm import DeepAR

ts = MockTs(dimensions=1) # you can change this for multivariate time-series! dpmodel = DeepAR(ts, epochs=50) dpmodel.instantiateandfit() ```

Plot results with uncertainty bands: ```python %matplotlib inline from numpy.random import normal import tqdm import pandas as pd from matplotlib import pyplot as plt import numpy as np

batch = ts.nextbatch(1, ts.nsteps)

ress = [] for i in tqdm.tqdm(range(300)): ress.append(np.expanddims( dpmodel.getsampleprediction( batch[0] ), axis=0, ))

res_np = np.concatenate(ress, axis=0) fig = plt.figure(figsize=(12, 10))

for dim in range(ts.dimensions): ax = fig.addsubplot(ts.dimensions, 1, dim+1) resdf = pd.DataFrame(resnp[:, :, 0]).T totres = res_df

ax.plot(batch[1].reshape((ts.n_steps, ts.dimensions))[:, dim], linewidth=6)
tot_res['mu'] = tot_res.apply(lambda x: np.mean(x), axis=1)
tot_res['upper'] = tot_res.apply(lambda x: np.mean(x) + np.std(x), axis=1)
tot_res['lower'] = tot_res.apply(lambda x: np.mean(x) - np.std(x), axis=1)
tot_res['two_upper'] = tot_res.apply(lambda x: np.mean(x) + 2*np.std(x), axis=1)
tot_res['two_lower'] = tot_res.apply(lambda x: np.mean(x) - 2*np.std(x), axis=1)

ax.plot(tot_res.mu, 'bo') ax.plot(tot_res.mu, linewidth=2) ax.fill_between(x = tot_res.index, y1=tot_res.lower, y2=tot_res.upper, alpha=0.5) ax.fill_between(x = tot_res.index, y1=tot_res.two_lower, y2=tot_res.two_upper, alpha=0.5) fig.suptitle('Prediction uncertainty')

Image of gaussian

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.