Histogram-weighted pairwise distances for node-wise feature data.
Project description
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.
Project details
Release history Release notifications | RSS feed
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 hiwenet-0.6.0.tar.gz.
File metadata
- Download URL: hiwenet-0.6.0.tar.gz
- Upload date:
- Size: 17.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.2 cpython/3.13.1 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1676f9ac50989a6c4911ad39fcbebb1058d84d3bbe97ea41d9bf6d3762c03211
|
|
| MD5 |
8956ba22ef2949eb6c2bc4f0298c4332
|
|
| BLAKE2b-256 |
0b47b680a349c3cf6587257b6e6f008f9fdb8546ff567ec1c4ddc37ae0431418
|
File details
Details for the file hiwenet-0.6.0-py3-none-any.whl.
File metadata
- Download URL: hiwenet-0.6.0-py3-none-any.whl
- Upload date:
- Size: 21.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Hatch/1.16.2 cpython/3.13.1 HTTPX/0.28.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
186bb00e93795e6e105ce43baa4e2420239e94365e8183fe71ba26fdf143f32f
|
|
| MD5 |
36fc94694bea3e65ee20204aea9df3a0
|
|
| BLAKE2b-256 |
38344d9d664639e26b5211d68835fe32ca4faff8bc4b8cf7fe8ac5767b2c8085
|