Skip to main content

Python wrapper for the R package huge

Project description

pyhuge Python Package

Python wrapper tests Python docs Python package release

pyhuge is the Python wrapper for the huge package: High-dimensional Undirected Graph Estimation.

Table of contents

Background

huge is widely used for sparse undirected graphical model estimation in high dimensions. pyhuge keeps the original R/C++ backend and exposes a Python API via rpy2 so Python users can:

  • call the same core methods (mb, glasso, ct, tiger);
  • run model selection (ric, stars, ebic);
  • access simulation, ROC, and inference helpers;
  • work with numpy and scipy.sparse objects directly.

Directory structure

The Python package directory is organized as:

  • pyhuge/: Python wrapper source code
  • tests/: unit/runtime/e2e tests
  • examples/: runnable scripts
  • docs/: MkDocs documentation pages
  • scripts/: release and docs build scripts

What this package provides

  • Thin and stable bridge to mature huge backend.
  • Argument validation with explicit PyHugeError messages.
  • Typed result objects.
  • Plot helpers including node-edge network visualization (huge_plot_network).
  • Tests, documentation website workflow, and release automation scripts.

Requirements

  • Python >=3.9
  • Runtime mode only: R installed and available in PATH
  • Runtime mode only: R package huge installed (with Rcpp, RcppEigen, igraph, etc.)
  • Runtime mode only: Python and R architecture must match (both arm64 or both x86_64)

Installation

Install from PyPI (recommended):

pip install pyhuge
pip install "pyhuge[runtime]"
R -q -e 'install.packages(c("huge","Rcpp","RcppEigen","igraph"), repos="https://cloud.r-project.org")'
pyhuge-doctor --require-runtime

Install from source:

git clone https://github.com/Gatech-Flash/huge.git
cd huge/python-package
pip install -e .
pip install -e ".[runtime]"

Install directly from GitHub:

pip install "git+https://github.com/Gatech-Flash/huge.git#subdirectory=python-package"

Optional extras:

pip install "pyhuge[viz]"      # matplotlib + networkx
pip install "pyhuge[runtime]"  # rpy2 bridge (required for model fitting)
pip install "pyhuge[release]"  # build + twine

Runtime check:

pyhuge-doctor

If runtime=False, verify R_LIBS_USER, architecture match, and huge visibility in R.

Usage

import numpy as np
from pyhuge import huge, huge_npn, huge_select

rng = np.random.default_rng(1)
x = rng.normal(size=(120, 30))
x_npn = huge_npn(x, npn_func="shrinkage", verbose=False)

fit = huge(x_npn, method="mb", nlambda=8, verbose=False)
sel = huge_select(fit, criterion="ric", verbose=False)
print(fit.method, len(fit.path), sel.opt_lambda, sel.opt_sparsity)

Network visualization:

import matplotlib.pyplot as plt
from pyhuge import huge_plot_network

fig, ax = plt.subplots(figsize=(5, 5))
huge_plot_network(fit, index=-1, ax=ax, layout="spring")
plt.show()

Documentation and tutorials

  • Website: https://gatech-flash.github.io/huge/
  • Docs source: python-package/docs
  • Function manual directory: python-package/docs/man (R man/-style layout)
  • Tutorial scripts: python-package/examples

Build docs locally:

cd python-package
mkdocs serve

Run tutorials/examples:

cd python-package
python examples/run_huge_mb.py
python examples/run_summary_and_plot.py
python examples/run_network_plot.py

If you use custom R library path:

R_LIBS_USER=/Users/tourzhao/Desktop/huge-master/.Rlib \
python examples/run_huge_mb.py

Performance notes

pyhuge runtime is dominated by R backend solve time for medium/large problems. For many tiny repeated calls, Python-R bridge overhead can matter. Benchmark backend and end-to-end workflows separately when tuning performance.

Implemented APIs

  • huge, huge_mb, huge_glasso, huge_ct, huge_tiger
  • huge_select, huge_npn
  • huge_generator, huge_inference, huge_roc
  • huge_summary, huge_select_summary
  • huge_plot_sparsity, huge_plot_roc, huge_plot_graph_matrix, huge_plot_network
  • test, doctor, format_doctor_report

For developer

cd python-package
pip install -e ".[dev]"
pytest
mkdocs build --strict
bash scripts/build_docs.sh
bash scripts/build_dist.sh

Optional e2e run with local R runtime:

export R_LIBS_USER=/Users/tourzhao/Desktop/huge-master/.Rlib
export PYHUGE_REQUIRE_RUNTIME=1
pytest tests/test_e2e_optional.py -rA

Workflows:

  • .github/workflows/python-wrapper-tests.yml
  • .github/workflows/python-package-docs.yml
  • .github/workflows/python-package-release.yml

Citation

If you use huge / pyhuge in research, cite:

@article{zhao2012huge,
  title   = {The huge Package for High-dimensional Undirected Graph Estimation in R},
  author  = {Zhao, Tuo and Liu, Han and Roeder, Kathryn and Lafferty, John and Wasserman, Larry},
  journal = {Journal of Machine Learning Research},
  volume  = {13},
  pages   = {1059--1062},
  year    = {2012}
}

References

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

pyhuge-0.2.3.tar.gz (42.3 kB view details)

Uploaded Source

Built Distribution

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

pyhuge-0.2.3-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file pyhuge-0.2.3.tar.gz.

File metadata

  • Download URL: pyhuge-0.2.3.tar.gz
  • Upload date:
  • Size: 42.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyhuge-0.2.3.tar.gz
Algorithm Hash digest
SHA256 b300993278a59a44eecfc22a3ca1dc665573ea97a5ad84d429fa2fc3d9785a91
MD5 9dd0bc86bce2a629e1994f90f6ac5f70
BLAKE2b-256 c97cff456e52f11e4ec6255c1d4dc868c6b06d9d95652e55bf9a9282ba546b38

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhuge-0.2.3.tar.gz:

Publisher: python-package-release.yml on Gatech-Flash/huge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pyhuge-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: pyhuge-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 15.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyhuge-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 17efc686c4e5ef4aa3eb57eab4373d99be28161cc36f722fa3355b70ebe67b7c
MD5 85aab4c027f3dc571dd6f032d7317a73
BLAKE2b-256 3d036f393a0f1059810ea58a9b75908f26247aef978f611bc7c83e2676a44c6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhuge-0.2.3-py3-none-any.whl:

Publisher: python-package-release.yml on Gatech-Flash/huge

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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