Python wrapper for the R package huge
Project description
pyhuge Python Package
pyhuge is the Python wrapper for the
huge package:
High-dimensional Undirected Graph Estimation.
Table of contents
- Background
- Directory structure
- What this package provides
- Requirements
- Installation
- Usage
- Documentation and tutorials
- Performance notes
- Implemented APIs
- For developer
- Citation
- References
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
numpyandscipy.sparseobjects directly.
Directory structure
The Python package directory is organized as:
pyhuge/: Python wrapper source codetests/: unit/runtime/e2e testsexamples/: runnable scriptsdocs/: MkDocs documentation pagesscripts/: release and docs build scripts
What this package provides
- Thin and stable bridge to mature
hugebackend. - Argument validation with explicit
PyHugeErrormessages. - 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
hugeinstalled (withRcpp,RcppEigen,igraph, etc.) - Runtime mode only: Python and R architecture must match (both
arm64or bothx86_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(Rman/-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_tigerhuge_select,huge_npnhuge_generator,huge_inference,huge_rochuge_summary,huge_select_summaryhuge_plot_sparsity,huge_plot_roc,huge_plot_graph_matrix,huge_plot_networktest,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
- T. Zhao, H. Liu, K. Roeder, J. Lafferty, and L. Wasserman, The huge Package for High-dimensional Undirected Graph Estimation in R, JMLR 13:1059-1062, 2012.
- Huge CRAN page: https://cran.r-project.org/package=huge
- Repository: https://github.com/Gatech-Flash/huge
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4d893b7854b79d1f01b0e0da1285d1746acae20b72fe7ef05f033068625d25bd
|
|
| MD5 |
e28e1f3b91fa0d8bcdfe436d8bd786cd
|
|
| BLAKE2b-256 |
78ac2076a4ba0265ac8dd00d12dc2b853e182255c4fcccf189f8c61fa49fbab6
|
Provenance
The following attestation bundles were made for pyhuge-0.2.2.tar.gz:
Publisher:
python-package-release.yml on Gatech-Flash/huge
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyhuge-0.2.2.tar.gz -
Subject digest:
4d893b7854b79d1f01b0e0da1285d1746acae20b72fe7ef05f033068625d25bd - Sigstore transparency entry: 983818256
- Sigstore integration time:
-
Permalink:
Gatech-Flash/huge@701ec9e742da64783498c1de0b30521b6050dbd8 -
Branch / Tag:
refs/tags/pyhuge-v0.2.2 - Owner: https://github.com/Gatech-Flash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package-release.yml@701ec9e742da64783498c1de0b30521b6050dbd8 -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3f7e0316815e42b76be7a448ed9e06b3620060f5bad9e0208872f36fe96451c
|
|
| MD5 |
596f66b54ede9abaf7ebbc81b1c0e2ab
|
|
| BLAKE2b-256 |
b78eb10bfe6fc946ec046e3866f27621895a6cca5bf8bd1871622483fd7cdff7
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyhuge-0.2.2-py3-none-any.whl -
Subject digest:
c3f7e0316815e42b76be7a448ed9e06b3620060f5bad9e0208872f36fe96451c - Sigstore transparency entry: 983818272
- Sigstore integration time:
-
Permalink:
Gatech-Flash/huge@701ec9e742da64783498c1de0b30521b6050dbd8 -
Branch / Tag:
refs/tags/pyhuge-v0.2.2 - Owner: https://github.com/Gatech-Flash
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-package-release.yml@701ec9e742da64783498c1de0b30521b6050dbd8 -
Trigger Event:
push
-
Statement type: