<div style="text-align:center">
<img src="https://github.com/AlexanderVNikitin/tsgm/raw/main/docs/_static/logo.png">
</div>
[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1l2VB6eUwvrxyu8iB30faGiQM5AKthc82?usp=sharing)
[![Pypi version](https://img.shields.io/pypi/v/tsgm)](https://pypi.org/project/tsgm/)
[![unit-tests](https://github.com/AlexanderVNikitin/tsgm/actions/workflows/test.yml/badge.svg?event=push)](https://github.com/AlexanderVNikitin/tsgm/actions?query=workflow%3ATests+branch%3Amain)
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-380/)
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/AlexanderVNikitin/tsgm/blob/main/LICENSE)
[![Last Commit](https://img.shields.io/github/last-commit/AlexanderVNikitin/tsgm)](https://github.com/AlexanderVNikitin/tsgm/commits/main)
[![arXiv](https://img.shields.io/badge/arXiv-2305.11567-b31b1b.svg)](https://arxiv.org/abs/2305.11567)
[![codecov](https://codecov.io/gh/AlexanderVNikitin/tsgm/branch/main/graph/badge.svg?token=UD38ANZ0M1)](https://codecov.io/gh/AlexanderVNikitin/tsgm)
# Time Series Generative Modeling (TSGM)
[Documentation](https://tsgm.readthedocs.io/en/latest/) |
[Tutorials](https://github.com/AlexanderVNikitin/tsgm/tree/main/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
```
### M1 and M2 chips:
To install `tsgm` on Apple M1 and M2 chips:
```bash
# Install tensorflow
conda install -c conda-forge tensorflow=2.9.1
# Install tsgm without dependencies
pip install tsgm --no-deps
# Install rest of the dependencies (separately here for clarity)
conda install tensorflow-probability scipy antropy statsmodels dtaidistance networkx optuna prettytable seaborn scikit-learn yfinance tqdm
```
## Train your generative model
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1l2VB6eUwvrxyu8iB30faGiQM5AKthc82?usp=sharing) Introductory Tutorial "[Getting started with TSGM](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/GANs/cGAN.ipynb)"
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1Vw9t4TlI1Nek_t6bMPyKcPPPqCiXfOK3?usp=sharing) Tutorial on using [Time Series Augmentations](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/augmentations.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1hubtddSX94KyLzuCTwmU6pAFBgBeiEB-?usp=sharing) Tutorial on [Evaluation of Synthetic Time Series Data](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/evaluation.ipynb)
- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1wpf9WeNVj5TkUcPF6EavVx-hUCOfyvUd?usp=sharing) Tutorial on using [Multiple GPUs or TPU with TSGM](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/Using%20Multiple%20GPUs%20or%20TPU.ipynb)
For more examples, see [our tutorials](./tutorials).
```python
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](https://tsgm.readthedocs.io/en/latest/) with a complete overview of the implemented methods,
* [Tutorials](https://github.com/AlexanderVNikitin/tsgm/tree/main/tutorials) that describe practical use-cases of the framework.
#### For contributors
```bash
git clone github.com/AlexanderVNikitin/tsgm
cd tsgm
pip install -e .
```
Run tests:
```bash
python -m pytest
```
To check static typing:
```bash
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](https://tsgm.readthedocs.io/en/latest/guides/datasets.html)
## 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](https://dl.acm.org/doi/pdf/10.1145/3136755.3136817) |
| Window warping | `tsgm.augmentations.WindowWarping` | [Data Augmentation for Time Series Classification using Convolutional Neural Networks](https://shs.hal.science/halshs-01357973/document) |
## Contributing
We appreciate all contributions. To learn more, please check [CONTRIBUTING.md](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](LICENSE)
Raw data
{
"_id": null,
"home_page": "https://github.com/AlexanderVNikitin/tsgm",
"name": "tsgm",
"maintainer": "Alexander Nikitin",
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "machine learning, deep learning, signal processing, temporal signal, time series, generative modeling, neural networks, GAN",
"author": "Alexander Nikitin",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/b6/5e/f69310653998d032b90db61fa615f62f5986fb8a2fd445dff6fceb0128bb/tsgm-0.0.5.tar.gz",
"platform": null,
"description": "<div style=\"text-align:center\">\n<img src=\"https://github.com/AlexanderVNikitin/tsgm/raw/main/docs/_static/logo.png\">\n</div>\n\n[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1l2VB6eUwvrxyu8iB30faGiQM5AKthc82?usp=sharing)\n[![Pypi version](https://img.shields.io/pypi/v/tsgm)](https://pypi.org/project/tsgm/)\n[![unit-tests](https://github.com/AlexanderVNikitin/tsgm/actions/workflows/test.yml/badge.svg?event=push)](https://github.com/AlexanderVNikitin/tsgm/actions?query=workflow%3ATests+branch%3Amain)\n[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-380/)\n[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/AlexanderVNikitin/tsgm/blob/main/LICENSE)\n[![Last Commit](https://img.shields.io/github/last-commit/AlexanderVNikitin/tsgm)](https://github.com/AlexanderVNikitin/tsgm/commits/main)\n\n[![arXiv](https://img.shields.io/badge/arXiv-2305.11567-b31b1b.svg)](https://arxiv.org/abs/2305.11567)\n[![codecov](https://codecov.io/gh/AlexanderVNikitin/tsgm/branch/main/graph/badge.svg?token=UD38ANZ0M1)](https://codecov.io/gh/AlexanderVNikitin/tsgm)\n\n# Time Series Generative Modeling (TSGM)\n\n[Documentation](https://tsgm.readthedocs.io/en/latest/) |\n[Tutorials](https://github.com/AlexanderVNikitin/tsgm/tree/main/tutorials)\n\n## About TSGM\n\nTSGM is an open-source framework for synthetic time series generation and augmentation. \n\nThe framework can be used for:\n- creating synthetic data, using historical data, black-box models, or a combined approach,\n- augmenting time series data,\n- evaluating synthetic data with respect to consistency, privacy, downstream performance, and more.\n\n\n## Install TSGM\n```\npip install tsgm\n```\n\n### M1 and M2 chips:\nTo install `tsgm` on Apple M1 and M2 chips:\n```bash\n# Install tensorflow\nconda install -c conda-forge tensorflow=2.9.1\n\n# Install tsgm without dependencies\npip install tsgm --no-deps\n\n# Install rest of the dependencies (separately here for clarity)\nconda install tensorflow-probability scipy antropy statsmodels dtaidistance networkx optuna prettytable seaborn scikit-learn yfinance tqdm\n```\n\n\n## Train your generative model\n\n- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1l2VB6eUwvrxyu8iB30faGiQM5AKthc82?usp=sharing) Introductory Tutorial \"[Getting started with TSGM](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/GANs/cGAN.ipynb)\"\n- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1Vw9t4TlI1Nek_t6bMPyKcPPPqCiXfOK3?usp=sharing) Tutorial on using [Time Series Augmentations](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/augmentations.ipynb)\n- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1hubtddSX94KyLzuCTwmU6pAFBgBeiEB-?usp=sharing) Tutorial on [Evaluation of Synthetic Time Series Data](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/evaluation.ipynb)\n- [![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/drive/1wpf9WeNVj5TkUcPF6EavVx-hUCOfyvUd?usp=sharing) Tutorial on using [Multiple GPUs or TPU with TSGM](https://github.com/AlexanderVNikitin/tsgm/blob/main/tutorials/Using%20Multiple%20GPUs%20or%20TPU.ipynb)\n\nFor more examples, see [our tutorials](./tutorials).\n\n```python\nimport tsgm\n\n# ... Define hyperparameters ...\n# dataset is a tensor of shape n_samples x seq_len x feature_dim\n\n# Zoo contains several prebuilt architectures: we choose a conditional GAN architecture\narchitecture = tsgm.models.architectures.zoo[\"cgan_base_c4_l1\"](\n seq_len=seq_len, feat_dim=feature_dim,\n latent_dim=latent_dim, output_dim=0)\ndiscriminator, generator = architecture.discriminator, architecture.generator\n\n# Initialize GAN object with selected discriminator and generator\ngan = tsgm.models.cgan.GAN(\n discriminator=discriminator, generator=generator, latent_dim=latent_dim\n)\ngan.compile(\n d_optimizer=keras.optimizers.Adam(learning_rate=0.0003),\n g_optimizer=keras.optimizers.Adam(learning_rate=0.0003),\n loss_fn=keras.losses.BinaryCrossentropy(from_logits=True),\n)\ngan.fit(dataset, epochs=N_EPOCHS)\n\n# Generate 100 synthetic samples\nresult = gan.generate(100)\n```\n\n\n## Getting started\n\nWe provide:\n* [Documentation](https://tsgm.readthedocs.io/en/latest/) with a complete overview of the implemented methods,\n* [Tutorials](https://github.com/AlexanderVNikitin/tsgm/tree/main/tutorials) that describe practical use-cases of the framework.\n\n\n#### For contributors\n```bash\ngit clone github.com/AlexanderVNikitin/tsgm\ncd tsgm\npip install -e .\n```\n\nRun tests:\n```bash\npython -m pytest\n```\n\nTo check static typing:\n```bash\nmypy\n```\n\n## CLI\nWe provide two CLIs for convenient synthetic data generation:\n- `tsgm-gd` generates data by a stored sample,\n- `tsgm-eval` evaluates the generated time series.\n\nUse `tsgm-gd --help` or `tsgm-eval --help` for documentation.\n\n\n## Datasets\nTSGM provides API for convenient use of many time-series datasets (currently more than 15 datasets). The comprehensive list of the datasets in the [documentation](https://tsgm.readthedocs.io/en/latest/guides/datasets.html)\n\n## Augmentations\nTSGM provides a number of time series augmentations.\n\n| Augmentation | Class in TSGM | Reference |\n| ------------- | ------------- | ------------- |\n| Gaussian Noise / Jittering | `tsgm.augmentations.GaussianNoise` | - | \n| Slice-And-Shuffle | `tsgm.augmentations.SliceAndShuffle` | - |\n| Shuffle features | `tsgm.augmentations.Shuffle` | - |\n| Magnitude warping | `tsgm.augmentations.MagnitudeWarping` | [Data Augmentation of Wearable Sensor Data for Parkinson\u2019s Disease Monitoring using Convolutional Neural Networks](https://dl.acm.org/doi/pdf/10.1145/3136755.3136817) |\n| Window warping | `tsgm.augmentations.WindowWarping` | [Data Augmentation for Time Series Classification using Convolutional Neural Networks](https://shs.hal.science/halshs-01357973/document) |\n\n\n## Contributing\nWe appreciate all contributions. To learn more, please check [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## Citing\nIf you find this repo useful, please consider citing our paper:\n```\n@article{\n nikitin2023tsgm,\n title={TSGM: A Flexible Framework for Generative Modeling of Synthetic Time Series},\n author={Nikitin, Alexander and Iannucci, Letizia and Kaski, Samuel},\n journal={arXiv preprint arXiv:2305.11567},\n year={2023}\n}\n```\n\n## License\n[Apache License 2.0](LICENSE)\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Time Series Generative Modelling Framework",
"version": "0.0.5",
"project_urls": {
"Homepage": "https://github.com/AlexanderVNikitin/tsgm"
},
"split_keywords": [
"machine learning",
" deep learning",
" signal processing",
" temporal signal",
" time series",
" generative modeling",
" neural networks",
" gan"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b65ef69310653998d032b90db61fa615f62f5986fb8a2fd445dff6fceb0128bb",
"md5": "6d58657ecc9402189692b6a78459968e",
"sha256": "2440d47e4f4e1a7fa2c1ede4c9c812616894e2e65f22d58abaade484635b557c"
},
"downloads": -1,
"filename": "tsgm-0.0.5.tar.gz",
"has_sig": false,
"md5_digest": "6d58657ecc9402189692b6a78459968e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 64933,
"upload_time": "2024-03-24T18:12:00",
"upload_time_iso_8601": "2024-03-24T18:12:00.234672Z",
"url": "https://files.pythonhosted.org/packages/b6/5e/f69310653998d032b90db61fa615f62f5986fb8a2fd445dff6fceb0128bb/tsgm-0.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-03-24 18:12:00",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AlexanderVNikitin",
"github_project": "tsgm",
"travis_ci": false,
"coveralls": true,
"github_actions": true,
"lcname": "tsgm"
}