Coder Social home page Coder Social logo

bluemk00 / brits-tensorflow Goto Github PK

View Code? Open in Web Editor NEW

This project forked from flaviagiammarino/brits-tensorflow

0.0 0.0 0.0 2.11 MB

TensorFlow implementation of BRITS model for multivariate time series imputation with bidirectional recurrent neural networks.

Home Page: https://doi.org/10.48550/arXiv.1805.10572

License: MIT License

Python 100.00%

brits-tensorflow's Introduction

BRITS TensorFlow

license languages

TensorFlow implementation of multivariate time series imputation model introduced in Cao, W., Wang, D., Li, J., Zhou, H., Li, L. and Li, Y., 2018. BRITS: Bidirectional recurrent imputation for time series. Advances in neural information processing systems, 31.

Dependencies

pandas==1.5.2
numpy==1.23.5
tensorflow==2.11.0
plotly==5.11.0
kaleido==0.2.1

Usage

import numpy as np

from brits_tensorflow.model import BRITS
from brits_tensorflow.plots import plot

# Generate some time series
N = 2000
t = np.linspace(0, 1, N)
e = np.random.multivariate_normal(mean=np.zeros(2), cov=np.eye(2), size=N)
a = 40 + 20 * np.cos(2 * np.pi * (10 * t - 0.5)) + e[:, 0]
b = 60 + 30 * np.cos(2 * np.pi * (20 * t - 0.5)) + e[:, 1]
x = np.hstack([a.reshape(- 1, 1), b.reshape(- 1, 1)])

# Add some missing values
for i in range(10):
    a = np.random.randint(low=200, high=N - 200, size=2)
    b = np.random.randint(low=5, high=50, size=2)
    for j in range(2):
        x[a[j]: a[j] + b[j], j] = np.nan
    
# Fit the model
model = BRITS(
    x=x,
    units=100,
    timesteps=200
)

model.fit(
    learning_rate=0.001,
    batch_size=16,
    epochs=200,
    verbose=True
)

# Impute the missing values
x_hat = model.impute(x=x)

# Plot the imputations
fig = plot(actual=x, imputed=x_hat)
fig.write_image('results.png', scale=4, height=900, width=700)

results

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