netbalance
netbalance is a Python library and CLI tool for balancing and visualizing multi-cluster interaction (association) networks.
Installation
pip install netbalance
Quick start
Balancing an interaction network using entity-balanced sampling:
cat data/virus-host.csv | netbalance --seed 0 --max-iter 1000
Balancing an interaction network using uniform random sampling with a 1:1 negative-to-positive ratio:
cat data/virus-host.csv | netbalance -m balanced --negative-ratio 1.0
Visualizing a bipartite network:
cat data/virus-host.csv | netbalance viz -o virus-host.png
Data format
All inputs are CSVs where the first N columns are entity names (one per cluster) and the last column is a binary label (1 = positive interaction, 0 = negative):
A,B,interaction
A1,B2,1
A1,B4,0
The viz subcommand requires exactly 2 entity columns (bipartite).
Python API
If you prefer to use the Python API instead of the CLI, see the example notebook.
Example usage
Balancing and visualizing a virus-host interaction network
The following cammand uses the entity-balanced sampling method to balance a virus-host interaction network, then visualizes the balanced network as a bipartite graph.
cat data/virus-host.csv | netbalance --seed 0 --max-iter 20000 --delta 0.001| netbalance viz -o virus-host.png
The resulting graph is shown below:
Entity-balanced sampling without the degree-ratio guided intialization
cat data/virus-host.csv | netbalance --seed 0 --max-iter 20000 --delta 0.001 --no-heuristic
Metadata
Release files for netbalance 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| netbalance-0.2.0.tar.gz | 3.4 MB | With provenance | Details for netbalance-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netbalance-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for netbalance-0.2.0-py3-none-any.whl |
Total release size: 3.4 MB
Release files / netbalance-0.2.0.tar.gz
| Download URL | netbalance-0.2.0.tar.gz |
|---|---|
| Size | 3.4 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
92ee002cb265d613fdd49243a7bc41c9e2806b6129d767be1da60d43b23d80bb
|
|
BLAKE2b-256 checksum How to use checksums |
6bafce153cadbf2ae4f641d832974e899141af6d0fb2f92b563b985dd00a8309
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 25, 2026.
Transparency logRelease files / netbalance-0.2.0-py3-none-any.whl
| Download URL | netbalance-0.2.0-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9ec6838787f1164a3f9c1e00c8255f885ae75d16d22537106ec89ca1befe3659
|
|
BLAKE2b-256 checksum How to use checksums |
1f1e438455d6075acae504e502cf0a6141da1b3e5f7cfe0a91e530542b11db80
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 25, 2026.
Transparency logSecurity for netbalance 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for netbalance-0.2.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.