Skip to main content

Time Series Generative Modelling Framework

Project description

Open in Colab Pypi version unit-tests Python 3.8+ License Last Commit

arXiv codecov

Time Series Generative Modeling (TSGM)

Documentation | Tutorials

About TSGM

TSGM is an open-source framework for synthetic time series generation and augmentation.

The framework can be used for:

  • creating synthetic data, using historical data, black-box models, or a combined approach,
  • augmenting time series data,
  • evaluating synthetic data with respect to consistency, privacy, downstream performance, and more.

Install TSGM

pip install tsgm

Train your generative model

For more examples, see our tutorials.

import tsgm

# ... Define hyperparameters ...
# dataset is a tensor of shape n_samples x seq_len x feature_dim

# Zoo contains several prebuilt architectures: we choose a conditional GAN architecture
architecture = tsgm.models.architectures.zoo["cgan_base_c4_l1"](
    seq_len=seq_len, feat_dim=feature_dim,
    latent_dim=latent_dim, output_dim=0)
discriminator, generator = architecture.discriminator, architecture.generator

# Initialize GAN object with selected discriminator and generator
gan = tsgm.models.cgan.GAN(
    discriminator=discriminator, generator=generator, latent_dim=latent_dim
)
gan.compile(
    d_optimizer=keras.optimizers.Adam(learning_rate=0.0003),
    g_optimizer=keras.optimizers.Adam(learning_rate=0.0003),
    loss_fn=keras.losses.BinaryCrossentropy(from_logits=True),
)
gan.fit(dataset, epochs=N_EPOCHS)

# Generate 100 synthetic samples
result = gan.generate(100)

Getting started

We provide:

  • Documentation with a complete overview of the implemented methods,
  • Tutorials that describe practical use-cases of the framework.

For contributors

git clone github.com/AlexanderVNikitin/tsgm
cd tsgm
pip install -e .

Run tests:

python -m pytest

To check static typing:

mypy

CLI

We provide two CLIs for convenient synthetic data generation:

  • tsgm-gd generates data by a stored sample,
  • tsgm-eval evaluates the generated time series.

Use tsgm-gd --help or tsgm-eval --help for documentation.

Datasets

TSGM provides API for convenient use of many time-series datasets (currently more than 15 datasets). The comprehensive list of the datasets in the documentation

Augmentations

TSGM provides a number of time series augmentations.

Augmentation Class in TSGM Reference
Gaussian Noise / Jittering tsgm.augmentations.GaussianNoise -
Slice-And-Shuffle tsgm.augmentations.SliceAndShuffle -
Shuffle features tsgm.augmentations.Shuffle -
Magnitude warping tsgm.augmentations.MagnitudeWarping Data Augmentation of Wearable Sensor Data for Parkinson’s Disease Monitoring using Convolutional Neural Networks
Window warping tsgm.augmentations.WindowWarping Data Augmentation for Time Series Classification using Convolutional Neural Networks

Contributing

We appreciate all contributions. To learn more, please check CONTRIBUTING.md.

Citing

If you find this repo useful, please consider citing our paper:

@article{
  nikitin2023tsgm,
  title={TSGM: A Flexible Framework for Generative Modeling of Synthetic Time Series},
  author={Nikitin, Alexander and Iannucci, Letizia and Kaski, Samuel},
  journal={arXiv preprint arXiv:2305.11567},
  year={2023}
}

License

Apache License 2.0

Project details


Download files

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

Source Distribution

tsgm-0.0.3.tar.gz (52.5 kB view details)

Uploaded Source

File details

Details for the file tsgm-0.0.3.tar.gz.

File metadata

  • Download URL: tsgm-0.0.3.tar.gz
  • Upload date:
  • Size: 52.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for tsgm-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0ddc6e6b73c07c2fba9b95533b0cccffb421c19279324c226418bfb327dd2f5f
MD5 9319683bbdfbf886db6cbc10f30dec2b
BLAKE2b-256 dc8bf3d29f42cc87d58a44e0c1ce7a85bf9c788a553d3ef0ff3ed37af213002e

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