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
  • R installed and available in PATH
  • R package huge installed (with Rcpp, RcppEigen, igraph, etc.)
  • Python and R architecture must match (both arm64 or both x86_64)

Installation

Install from source:

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

Install directly from GitHub:

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

Optional extras:

pip install -e ".[viz]"      # matplotlib + networkx
pip install -e ".[release]"  # build + twine
pip install -e ".[dev]"      # test + docs + release deps

Runtime check:

python -c "import pyhuge; print(pyhuge.test())"

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

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.1.tar.gz (32.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.1-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyhuge-0.2.1.tar.gz
  • Upload date:
  • Size: 32.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.1.tar.gz
Algorithm Hash digest
SHA256 ba0ddfb59fb66ec3864bf3ccd1fbf53127b6dcfbf3685d8cfae5623eabe3638f
MD5 ff5920303c4b1b4352bc04a31fca4e39
BLAKE2b-256 aef2dbb474bff1cf3407eff9444c9ea0b3cd6f08d5b1fdb633983a26b5535bdd

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhuge-0.2.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: pyhuge-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.8 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 fbc094d1e2dc31b0e4cfc8817159b3fccb6e9d7c83f5d6a4c3dbc5fc3adc780c
MD5 95e4f24874ec0ed11dafb7427736dd5d
BLAKE2b-256 4467a999552c338b5efb6306372e4464aff78c33de8d119cc47a85689187c544

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyhuge-0.2.1-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