freqdiff


Namefreqdiff JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryTime series diffusion in the frequency domain.
upload_time2024-02-09 10:41:14
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT License Copyright (c) 2023 JonathanCrabbe Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords diffusion time series fourier frequency generative machine learning ai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Time Series Diffusion in the Frequency Domain

This repository implements time series diffusion in the frequency domain.
For more details, please read our paper: [Time Series Diffusion in the Frequency Domain](https://arxiv.org/abs/2402.05933).
 
# 1. Install


From repository:
1. Clone the repository.
2. Create and activate a new environment with conda (with `Python 3.10` or newer).

```shell
conda env create -n fdiff python=3.10
conda activate fdiff
```
3. Install the requirement.
```shell
pip install -e .
```

4. If you intend to train models, make sure that wandb is correctly configured on your machine by following [this guide](https://docs.wandb.ai/quickstart). 
5. Some of the datasets are automatically downloaded by our scripts via kaggle API. Make sure to create a kaggle token as explained [here](https://towardsdatascience.com/downloading-datasets-from-kaggle-for-your-ml-project-b9120d405ea4).

When the packages are installed, you are ready to train diffusion models!

# 2. Use

## 2.1 Train
In order to train models, you can simply run the following command:

```shell
python cmd/train.py 
```

By default, this command will train a score model in the time domain with the `ecg` dataset. In order to modify this behaviour, you can use [hydra override syntax](https://hydra.cc/docs/advanced/override_grammar/basic/). The following hyperparameters can be modified to retrain all the models appearing in the paper:

| Hyperparameter | Description | Values |
|----------------|-------------|---------------|
|fourier_transform | Whether or not to train a diffusion model in the frequency domain. | true, false |
| datamodule | Name of the dataset to use. | ecg, mimiciii, nasa, nasdaq, usdroughts|
| datamodule.subdataset | For the NASA dataset only. Selects between the charge and discharge subsets. | charge, discharge |
| datamodule.smoother_width | For the ECG dataset only. Width of the Gaussian kernel smoother applied in the frequency domain. | $\mathbb{R}^+$
| score_model | The backbone to use for the score model. | default, lstm |

At the end of training, your model is stored in the `lightning_logs` directory, in a folder named after the current `run_id`. You can find the `run_id` in the logs of the training and in the [wandb dashboard](https://wandb.ai/) if you have correctly configured wandb.

## 2.2 Sample

In order to sample from a trained model, you can simply run the following command:

```shell
python cmd/sample.py model_id=XYZ
```
    
where `XYZ` is the `run_id` of the model you want to sample from. At the end of sampling, the samples are stored in the `lightning_logs` directory, in a folder named after the current `run_id`. 

One can then reproduce the plots in the paper by including the  `run_id` to the `run_list` list appearing in [this notebook](notebooks/results.ipynb) and running all cells.

# 3. Contribute

If you wish to contribute, please make sure that your code is compliant with our tests and coding conventions. To do so, you should install the required testing packages with:

```shell
pip install -e .[test]
```

Then, you can run the tests with:

```shell
pytest
```

Before any commit, please make sure that your staged code is compliant with our coding conventions by running:

```shell
pre-commit
```

# 4. Cite us
If you use this code, please acknowledge our work by citing

```
@misc{crabbé2024time,
      title={Time Series Diffusion in the Frequency Domain}, 
      author={Jonathan Crabbé and Nicolas Huynh and Jan Stanczuk and Mihaela van der Schaar},
      year={2024},
      eprint={2402.05933},
      archivePrefix={arXiv},
      primaryClass={cs.LG}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "freqdiff",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "Jonathan Crabb\u00e9 <jonathan.cr1302@gmail.com>",
    "keywords": "diffusion,time,series,fourier,frequency,generative,machine,learning,ai",
    "author": "",
    "author_email": "Jonathan Crabb\u00e9 <jonathan.cr1302@gmail.com>, Nicolas Huynh <nicolas.huynh99@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/b6/3c/6e4ce9461de0dec213f16eafa8558311cca7984bd2eb570e1972b7c45564/freqdiff-0.1.0.tar.gz",
    "platform": null,
    "description": "# Time Series Diffusion in the Frequency Domain\n\nThis repository implements time series diffusion in the frequency domain.\nFor more details, please read our paper: [Time Series Diffusion in the Frequency Domain](https://arxiv.org/abs/2402.05933).\n \n# 1. Install\n\n\nFrom repository:\n1. Clone the repository.\n2. Create and activate a new environment with conda (with `Python 3.10` or newer).\n\n```shell\nconda env create -n fdiff python=3.10\nconda activate fdiff\n```\n3. Install the requirement.\n```shell\npip install -e .\n```\n\n4. If you intend to train models, make sure that wandb is correctly configured on your machine by following [this guide](https://docs.wandb.ai/quickstart). \n5. Some of the datasets are automatically downloaded by our scripts via kaggle API. Make sure to create a kaggle token as explained [here](https://towardsdatascience.com/downloading-datasets-from-kaggle-for-your-ml-project-b9120d405ea4).\n\nWhen the packages are installed, you are ready to train diffusion models!\n\n# 2. Use\n\n## 2.1 Train\nIn order to train models, you can simply run the following command:\n\n```shell\npython cmd/train.py \n```\n\nBy default, this command will train a score model in the time domain with the `ecg` dataset. In order to modify this behaviour, you can use [hydra override syntax](https://hydra.cc/docs/advanced/override_grammar/basic/). The following hyperparameters can be modified to retrain all the models appearing in the paper:\n\n| Hyperparameter | Description | Values |\n|----------------|-------------|---------------|\n|fourier_transform | Whether or not to train a diffusion model in the frequency domain. | true, false |\n| datamodule | Name of the dataset to use. | ecg, mimiciii, nasa, nasdaq, usdroughts|\n| datamodule.subdataset | For the NASA dataset only. Selects between the charge and discharge subsets. | charge, discharge |\n| datamodule.smoother_width | For the ECG dataset only. Width of the Gaussian kernel smoother applied in the frequency domain. | $\\mathbb{R}^+$\n| score_model | The backbone to use for the score model. | default, lstm |\n\nAt the end of training, your model is stored in the `lightning_logs` directory, in a folder named after the current `run_id`. You can find the `run_id` in the logs of the training and in the [wandb dashboard](https://wandb.ai/) if you have correctly configured wandb.\n\n## 2.2 Sample\n\nIn order to sample from a trained model, you can simply run the following command:\n\n```shell\npython cmd/sample.py model_id=XYZ\n```\n    \nwhere `XYZ` is the `run_id` of the model you want to sample from. At the end of sampling, the samples are stored in the `lightning_logs` directory, in a folder named after the current `run_id`. \n\nOne can then reproduce the plots in the paper by including the  `run_id` to the `run_list` list appearing in [this notebook](notebooks/results.ipynb) and running all cells.\n\n# 3. Contribute\n\nIf you wish to contribute, please make sure that your code is compliant with our tests and coding conventions. To do so, you should install the required testing packages with:\n\n```shell\npip install -e .[test]\n```\n\nThen, you can run the tests with:\n\n```shell\npytest\n```\n\nBefore any commit, please make sure that your staged code is compliant with our coding conventions by running:\n\n```shell\npre-commit\n```\n\n# 4. Cite us\nIf you use this code, please acknowledge our work by citing\n\n```\n@misc{crabb\u00e92024time,\n      title={Time Series Diffusion in the Frequency Domain}, \n      author={Jonathan Crabb\u00e9 and Nicolas Huynh and Jan Stanczuk and Mihaela van der Schaar},\n      year={2024},\n      eprint={2402.05933},\n      archivePrefix={arXiv},\n      primaryClass={cs.LG}\n}\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 JonathanCrabbe  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Time series diffusion in the frequency domain.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/JonathanCrabbe/FourierDiffusion/",
        "Source": "https://github.com/JonathanCrabbe/FourierDiffusion/"
    },
    "split_keywords": [
        "diffusion",
        "time",
        "series",
        "fourier",
        "frequency",
        "generative",
        "machine",
        "learning",
        "ai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b63c6e4ce9461de0dec213f16eafa8558311cca7984bd2eb570e1972b7c45564",
                "md5": "0dd4fd4bd2d9dbeb966516ee8008870a",
                "sha256": "9be5fafd56a15609341517c0edebbfc3c0117f993892d55d2b239e7ce1c4bfc2"
            },
            "downloads": -1,
            "filename": "freqdiff-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0dd4fd4bd2d9dbeb966516ee8008870a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 34056,
            "upload_time": "2024-02-09T10:41:14",
            "upload_time_iso_8601": "2024-02-09T10:41:14.588255Z",
            "url": "https://files.pythonhosted.org/packages/b6/3c/6e4ce9461de0dec213f16eafa8558311cca7984bd2eb570e1972b7c45564/freqdiff-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-09 10:41:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "JonathanCrabbe",
    "github_project": "FourierDiffusion",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "freqdiff"
}
        
Elapsed time: 0.19494s