Histogram-weighted Networks (hiwenet)
hiwenet computes pairwise distances between groups of node-wise feature
values. Its main role today is as the numerical engine behind
graynet, but it can also be used
directly whenever you need histogram-based or original-distribution-based
distances between groups.
Given:
- a 1D array of feature values
- a matching 1D array of group labels
- a distance metric
hiwenet returns either:
- a pairwise distance matrix
- an in-memory NetworkX graph with the same edge weights
This release is intentionally programmatic and does not provide a CLI.
Installation
pip install -U hiwenet
Quick Start
import numpy as np
from hiwenet import extract
features = np.array([0.2, 0.1, 0.3, 1.0, 1.2, 0.9])
groups = np.array([0, 0, 0, 1, 1, 1])
edge_weights = extract(
features,
groups,
weight_method="manhattan",
)
The default output matches what graynet expects: a square NumPy array whose
upper triangle stores the pairwise edge weights.
API
extract
extract() is the main entry point.
from hiwenet import extract
edge_weights = extract(
features,
groups,
weight_method="manhattan",
num_bins=25,
edge_range=None,
trim_outliers=True,
trim_percentile=5,
use_original_distribution=False,
relative_to_all=False,
asymmetric=False,
return_networkx_graph=False,
)
ExtractConfig
If you prefer a validated configuration object:
from hiwenet import ExtractConfig, extract_with_config
config = ExtractConfig(
weight_method="manhattan",
num_bins=25,
)
edge_weights = extract_with_config(features, groups, config)
Metrics
hiwenet supports both histogram-based distances and distances that operate on
the original values in each group.
Histogram-based metrics include:
manhattaneuclideanchebyshevbraycurtiscanberracosinecorrelationemdkl_divergencejs_divergence
Original-distribution metrics include:
diff_mediansdiff_medians_absdiff_meansdiff_means_absexp_diff_means_norm_stdranksum_statistic
Custom callables are also supported.
Relative-To-All
relative_to_all=True remains available for workflows that compare each group
against the pooled distribution from all groups.
Scientific Notes
- Explicit
edge_rangevalues are useful when you need consistent histogram support across subjects. - Built-in non-histogram metrics operate on the original values in each group.
- Degenerate histogram cases are handled deterministically in this release
instead of relying on runtime-warning-driven
NaNoutputs.
Development
pytest -q
hatch build
Citation
If hiwenet is useful in your work, please cite the JOSS paper linked above.
Metadata
Release files for hiwenet 0.6.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 |
|---|---|---|---|---|
| hiwenet-0.6.0.tar.gz | 17.5 kB | Without provenance | Details for hiwenet-0.6.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hiwenet-0.6.0-py3-none-any.whl | Python 3 | none | any | Details for hiwenet-0.6.0-py3-none-any.whl |
Total release size: 39.2 kB
Release files / hiwenet-0.6.0.tar.gz
| Download URL | hiwenet-0.6.0.tar.gz |
|---|---|
| Size | 17.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1676f9ac50989a6c4911ad39fcbebb1058d84d3bbe97ea41d9bf6d3762c03211
|
|
BLAKE2b-256 checksum How to use checksums |
0b47b680a349c3cf6587257b6e6f008f9fdb8546ff567ec1c4ddc37ae0431418
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.2 cpython/3.13.1 HTTPX/0.28.1
|
Release files / hiwenet-0.6.0-py3-none-any.whl
| Download URL | hiwenet-0.6.0-py3-none-any.whl |
|---|---|
| Size | 21.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
186bb00e93795e6e105ce43baa4e2420239e94365e8183fe71ba26fdf143f32f
|
|
BLAKE2b-256 checksum How to use checksums |
38344d9d664639e26b5211d68835fe32ca4faff8bc4b8cf7fe8ac5767b2c8085
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Hatch/1.16.2 cpython/3.13.1 HTTPX/0.28.1
|
Security for hiwenet 0.6.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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A 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.