Giter Site home page Giter Site logo

shesterg / probcast-tensorflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flaviagiammarino/probcast-tensorflow

0.0 0.0 0.0 579 KB

TensorFlow implementation of ProbCast model for multivariate time series forecasting with generative adversarial networks.

License: MIT License

Python 100.00%

probcast-tensorflow's Introduction

ProbCast TensorFlow

TensorFlow implementation of multivariate time series forecasting model introduced in Koochali, A., Dengel, A., & Ahmed, S. (2021). If You Like It, GAN It โ€” Probabilistic Multivariate Times Series Forecast with GAN. In Engineering Proceedings (Vol. 5, No. 1, p. 40). Multidisciplinary Digital Publishing Institute. https://doi.org/10.3390/engproc2021005040.

Dependencies

pandas==1.3.4
numpy==1.19.5
tensorflow==2.7.0
plotly==5.3.1
kaleido==0.2.1

Usage

import numpy as np
from probcast_tensorflow.model import ProbCast

# Generate two time series
N = 300
t = np.linspace(0, 1, N)
e = np.random.multivariate_normal(mean=[0, 0], cov=[[1, 0.25], [0.25, 1]], size=N)
a = 20 * np.cos(2 * np.pi * (10 * t - 0.5)) + e[:, 0]
b = 10 * np.sin(2 * np.pi * (20 * t - 0.5)) + e[:, 1]
y = np.hstack([a.reshape(- 1, 1), b.reshape(- 1, 1)])

# Fit the model
model = ProbCast(
    y=y,
    forecast_length=30,
    sequence_length=60,
    quantiles=[0.1, 0.3, 0.5, 0.7, 0.9],
    generator_gru_units=[64, 32],
    discriminator_gru_units=[64, 32],
    generator_dense_units=16,
    discriminator_dense_units=16,
    noise_dimension=100,
    noise_dispersion=10,
)

model.fit(
    learning_rate=0.001,
    batch_size=32,
    epochs=100,
    verbose=True
)
# Plot the in-sample predictions
predictions = model.predict(index=270)
fig = model.plot_predictions()
fig.write_image('predictions.png', width=750, height=650)

predictions

# Plot the out-of-sample forecasts
forecasts = model.forecast()
fig = model.plot_forecasts()
fig.write_image('forecasts.png', width=750, height=650)

forecasts

probcast-tensorflow's People

Contributors

flaviagiammarino avatar

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.