Skip to main content

Torch - Higher Order Interactions

Project description

THOI: Torch - Higher Order Interactions

THOI Logo

Description

THOI is a Python package designed to compute O information in Higher Order Interactions using batch processing. This package leverages PyTorch for efficient tensor operations.

Installation

Prerequisites

Ensure you have Python 3.6 or higher installed.

Installing THOI with your prefered Versions of PyTorch

Because PyTorch installation can depend on the user environment and requirements (GPU or CPU support or a specific version of PyTorch), you need to install PyTorch separately before installing THOI. Follow these steps:

  1. Visit the official PyTorch installation guide:

    • Go to the PyTorch website and navigate to the "Get Started" page.
    • Select your preferences for the following options:
      • PyTorch Build: Stable or LTS (long-term support)
      • Your Operating System: Linux, Mac, or Windows
      • Package: Pip (recommended)
      • Language: Python
      • Compute Platform: CPU, CUDA 10.2, CUDA 11.1, etc.
  2. Get the Installation Command:

    • Based on your selections, the PyTorch website will provide the appropriate installation command.

    • For example, for the CPU-only version, the command will look like this:

      pip install torch==1.8.1+cpu -f https://download.pytorch.org/whl/torch_stable.html
      
    • For the GPU version with CUDA 11.1, the command will look like this:

      pip install torch==1.8.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html
      
  3. Install PyTorch:

    • Copy and run the command provided by the PyTorch website in your terminal.
  4. Install THOI:

    • Once PyTorch is installed, install THOI using:

      pip install thoi
      

Usage

After installation, you can start using THOI in your projects. Here is a simple example:

from thoi.measures.gaussian_copula import multi_order_measures, nplets_measures
from thoi.heuristics import simulated_annealing, greedy
import numpy as np

X = np.random.normal(0,1, (1000, 10))

# Computation of O information for the nplet that consider all the variables of X
measures = nplets_measures(X)

# Computation of O info for a single nplet (it must be a list of nplets even if it is a single nplet)
measures = nplets_measures(X, [[0,1,3]])

# Computation of O info for multiple nplets
measures = nplets_measures(X, [[0,1,3],[3,7,4],[2,6,3]])

# Extensive computation of O information measures over all combinations of features in X
measures = multi_order_measures(X)

# Compute the best 10 combinations of features (nplet) using greedy, starting by exaustive search in 
# lower order and building from there. Result shows best O information for 
# each built optimal orders
best_nplets, best_scores = greedy(X, 3, 5, repeat=10)

# Compute the best 10 combinations of features (nplet) using simulated annealing: There are two initialization options
# 1. Starting by a custom initial solution with shape (repeat, order) explicitely provided by the user.
# 2. Selecting random samples from the order.
# Result shows best O information for each built optimal orders
best_nplets, best_scores = simulated_annealing(X, 5, repeat=10)

For detailed usage and examples, please refer to the documentation.

Contributing

We welcome contributions from the community. If you encounter any issues or have suggestions for improvements, please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Citation

If you use the thoi library in a scientific project, please cite it using one of the following formats:

BibTeX

@article{belloli2025thoi,
  title={THOI: An efficient and accessible library for computing higher-order interactions enhanced by batch-processing},
  author={Belloli, Laouen and Mediano, Pedro and Cofr{\'e}, Rodrigo and Slezak, Diego Fernandez and Herzog, Rub{\'e}n},
  journal={arXiv preprint arXiv:2501.03381},
  year={2025}
}

APA Belloli, L., Mediano, P., Cofré, R., Slezak, D. F., & Herzog, R. (2025). THOI: An efficient and accessible library for computing higher-order interactions enhanced by batch-processing. arXiv preprint arXiv:2501.03381.

MLA Belloli, Laouen, et al. "THOI: An efficient and accessible library for computing higher-order interactions enhanced by batch-processing." arXiv preprint arXiv:2501.03381 (2025).

Authors

For more details, visit the GitHub repository.

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

thoi-0.2.37.tar.gz (14.4 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

thoi-0.2.37-py3-none-any.whl (33.3 kB view details)

Uploaded Python 3

File details

Details for the file thoi-0.2.37.tar.gz.

File metadata

  • Download URL: thoi-0.2.37.tar.gz
  • Upload date:
  • Size: 14.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for thoi-0.2.37.tar.gz
Algorithm Hash digest
SHA256 9bc3b7ba75dfdf224e0bacda0a7eca560d875feb761bf157506865d344900432
MD5 0752dece6a85965431adbd6a1137896a
BLAKE2b-256 5a436dd8e74e521c4b7c4bb0936ce97a7d1e18ad89614e17fd3f8195d765f939

See more details on using hashes here.

File details

Details for the file thoi-0.2.37-py3-none-any.whl.

File metadata

  • Download URL: thoi-0.2.37-py3-none-any.whl
  • Upload date:
  • Size: 33.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.23

File hashes

Hashes for thoi-0.2.37-py3-none-any.whl
Algorithm Hash digest
SHA256 16109356f4c7c17042d05ef4d871624c1a8114a3d210b9743e413537f52ad453
MD5 73e8f028413522a07ee56cbb44c54248
BLAKE2b-256 c964e06fd11d8e77f172e61eb330414fb5a95e068dfc27ac6d6a7b01a5fce915

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page