Skip to main content

Fourier-flows 🌀

Code for the Generative Time-series Modeling with Fourier Flows paper.

Code author: Ahmed Alaa

Description

Generating synthetic time-series data is crucial in various application domains, such as medical prognosis, wherein research is hamstrung by the lack of access to data due to concerns over privacy.

Most of the recently proposed methods for generating synthetic time-series rely on implicit likelihood modeling using generative adversarial networks (GANs)—but such models can be difficult to train, and may jeopardize privacy by “memorizing” temporal patterns in training data.

In this paper, we propose an explicit likelihood model based on a novel class of normalizing flows that view time-series data in the frequency-domain rather than the time-domain. The proposed flow, dubbed a Fourier flow, uses a discrete Fourier transform (DFT) to convert variable-length time-series with arbitrary sampling periods into fixed-length spectral representations, then applies a (data-dependent) spectral filter to the frequency-transformed time-series. We show that, by virtue of the DFT analytic properties, the Jacobian determinants and inverse mapping for the Fourier flow can be computed efficiently in linearithmic time, without imposing explicit structural constraints as in existing flows such as NICE (Dinh et al. (2014)), RealNVP (Dinh et al. (2016)) and GLOW (Kingma & Dhariwal (2018)).

Installation

Install with pip:

pip install fflows

Examples

Fit a Fourier flow

import numpy as np
from fflows import FourierFlow

T = 11
n_samples = 100
dims = 3
X = np.random.randn(n_samples, T, dims)

model_params = {
    "hidden": 11,
    "n_flows": 11,
}
train_params = {
    "epochs": 10,
    "batch_size": 500,
    "learning_rate": 1e-3,
    "display_step": 100,
}

model = FourierFlow(**model_params)
model.fit(X, **train_params)

Generate new data

samples = model.sample(10)

assert samples.shape == (10, T, dims)

Data

The public datasets used in the paper are available at:

Experiments

Citing

Please cite using:

@inproceedings{alaa2020generative,
  title={Generative Time-series Modeling with Fourier Flows},
  author={Alaa, Ahmed and Chan, Alex James and van der Schaar, Mihaela},
  booktitle={International Conference on Learning Representations},
  year={2021}
}

Metadata

Release files for fflows 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for fflows 0.0.3
File Interpreter ABI Platform
fflows-0.0.3-py3-none-macosx_10_14_x86_64.whl Python 3 none macOS 10.14+ x86-64 Details
fflows-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 39.8 kB

Release files / fflows-0.0.3-py3-none-macosx_10_14_x86_64.whl

Download URL fflows-0.0.3-py3-none-macosx_10_14_x86_64.whl
Size 19.9 kB
Tags Python 3 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
c6101a5b3ebf241cf3bb473420ac1669759e4ca84fabbb09fb576d16eb2b6928
BLAKE2b-256 checksum
How to use checksums
5693eba05d84a28ed2f1885a37d528f6b4bef6e8aabae19d0a104a6439570a24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.13

Release files / fflows-0.0.3-py3-none-any.whl

Download URL fflows-0.0.3-py3-none-any.whl
Size 20.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
18de7a7b98e3708ff2d5ae9f10fad625740230c4de6447906b7ca477667b78fb
BLAKE2b-256 checksum
How to use checksums
3078b5d1e92ef17cbf0bf1fa97266f58a128b466d20ee1d6c444f652e92583d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page