Skip to main content

yet another vine copula library for PyTorch.

Project description

TorchVineCopuLib

Codacy Badge Codacy Badge Lint Pytest Deploy Docs

PyPI - Python Version OS

GitHub License PyPI - Version DOI

Yet another vine copula package, using PyTorch.

  • C/D/R-Vine full-simulation/ quantile-regression/ conditional-simulation, all in one package
    • Flexible simulation workflow for experienced users
  • Vectorized tensor computation with GPU (device='cuda') support
  • Shorter runtimes for higher dimension simulations
  • Decoupled dataclasses and factory methods
  • Pure Python library, inspired by and tested against pyvinecopulib on Windows, Linux, MacOS
  • IO and visualization support

Dependencies

# inside the `./pyproject.toml` file;
numpy = "*"
python = "^3.10"
scipy = "*"
# optional to facilitate customization
torch = { version = "^2", optional = true }

For PyTorch with cuda support on Windows:

pip install torch --index-url https://download.pytorch.org/whl/cu121 --force-reinstall
# check cuda availability
python -c "import torch; print(torch.cuda.is_available())"

[!TIP] macOS users should set device='cpu' at this stage, for using device='mps' won't support dtype=torch.float64.

Installation

pip install torchvinecopulib torch
  • Or with full drawing and bivariate dependency metric support:
pip install torchvinecopulib torch matplotlib pot scikit-learn
  • Or pip from ./dist/*.whl or ./dist/*.tar.gz in this repo. Need to use proper file name.
# inside project root folder
pip install ./dist/torchvinecopulib-2024.10.1-py3-none-any.whl
# or
pip install ./dist/torchvinecopulib-2024.10.1.tar.gz

(Optional) Poetry for Dependency Management and Packaging

After git clone https://github.com/TY-Cheng/torchvinecopulib.git, cd into the project root where pyproject.toml exists,

# inside project root folder
poetry lock && poetry install -E dev_cpu --with dev_cpu --sync
# or
poetry lock && poetry install -E dev_cuda --with dev_cuda --sync

Examples

Visit the ./examples/ folder for .ipynb Jupyter notebooks.

Documentation

# inside project root folder
sphinx-apidoc -o ./docs ./torchvinecopulib && cd ./docs && make html && cd ..

Tests

[!TIP] the ./tests/test_vinecop.py may take longer without 'cuda'

# inside project root folder
python -m pytest ./tests
# coverage report
coverage run -m pytest ./tests && coverage html

TODO

  • more (non-parametric) bicop class in torch
  • port to TensorFlow Probability for cuda-compatible Student's t cdf/ppf

Contributing

We welcome contributions, whether it's a bug report, feature suggestion, code contribution, or documentation improvement.

  • If you encounter any issues with the project or have ideas for new features, please open an issue on GitHub or privately email us. Make sure to include detailed information about the problem or feature request, including steps to reproduce for bugs.

Code Contributions

  1. Fork the repository and create a new branch from the main branch.
  2. Make your changes and ensure they adhere to the project's coding style and conventions.
  3. Write tests for any new functionality and ensure existing tests pass.
  4. Commit your changes with clear and descriptive commit messages.
  5. Push your changes to your fork and submit a pull request to the main branch of the original repository.

Pull Request Guidelines

  • Keep pull requests focused on addressing a single issue or feature.
  • Include a clear and descriptive title and description for your pull request.
  • Make sure all tests pass before submitting the pull request.
  • If your pull request addresses an open issue, reference the issue number in the description using the syntax #issue_number.
  • in-place ops can be slower
  • torch.jit.script can be slower

License

Copyright (C) 2024- Tuoyuan Cheng, Kan Chen

This file is part of torchvinecopulib. torchvinecopulib is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

torchvinecopulib is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with torchvinecopulib. If not, see http://www.gnu.org/licenses/.

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

torchvinecopulib-2024.10.1.tar.gz (52.4 kB view details)

Uploaded Source

Built Distribution

torchvinecopulib-2024.10.1-py3-none-any.whl (57.0 kB view details)

Uploaded Python 3

File details

Details for the file torchvinecopulib-2024.10.1.tar.gz.

File metadata

  • Download URL: torchvinecopulib-2024.10.1.tar.gz
  • Upload date:
  • Size: 52.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.11 Windows/10

File hashes

Hashes for torchvinecopulib-2024.10.1.tar.gz
Algorithm Hash digest
SHA256 21bfc6a5aaec1856800185d33cbe1cef2b2d041e6b17b5d1b99483f6deafab46
MD5 71dc27bd2695449db685d5d0519a7a04
BLAKE2b-256 49a9b80f7079f6ebb6c08344f140a4c3a50d3b1692ac0db0144a72f8a3254b7e

See more details on using hashes here.

File details

Details for the file torchvinecopulib-2024.10.1-py3-none-any.whl.

File metadata

File hashes

Hashes for torchvinecopulib-2024.10.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f60d20f9ce34d5a3d6916fb3858c31fbf67289573eccd114e7461d3a3a59e377
MD5 a27863a7164db1c413a2554284e82a4a
BLAKE2b-256 f13330ff2953d55b8c9c3e2700dc31c3ba90458e3c8ca0636ad33110624dec13

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