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.2.tar.gz (36.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.2-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyhuge-0.2.2.tar.gz
  • Upload date:
  • Size: 36.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.2.tar.gz
Algorithm Hash digest
SHA256 4d893b7854b79d1f01b0e0da1285d1746acae20b72fe7ef05f033068625d25bd
MD5 e28e1f3b91fa0d8bcdfe436d8bd786cd
BLAKE2b-256 78ac2076a4ba0265ac8dd00d12dc2b853e182255c4fcccf189f8c61fa49fbab6

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: pyhuge-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 14.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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c3f7e0316815e42b76be7a448ed9e06b3620060f5bad9e0208872f36fe96451c
MD5 596f66b54ede9abaf7ebbc81b1c0e2ab
BLAKE2b-256 b78eb10bfe6fc946ec046e3866f27621895a6cca5bf8bd1871622483fd7cdff7

See more details on using hashes here.

Provenance

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