Skip to main content

Weighted Jaccard methodology for correlation network analysis. Bidirectional regime detection and pairing-family decomposition.

Project description

wjpy — Weighted Jaccard Methodology for Correlation Network Analysis

PyPI version License: MIT DOI

A Python package implementing the Weighted Jaccard (WJ) methodology and pairing-family decomposition for correlation network analysis. Detects bidirectional structural regimes — both convergence and divergence — and separates magnitude-component reorganization from sign-component reorganization.

Why WJ

Most correlation-network analysis collapses two structurally distinct reorganization modes into one number:

  • Magnitude reorganization: correlations grow or shrink uniformly (financial crises).
  • Sign reorganization: correlations flip polarity without changing magnitude (regime transitions, calm-era decorrelation).

wjpy implements the unsigned, signed, and binary Jaccard variants — and the gap between them — as separate, interpretable measurements. Validated empirically across genomics (GTEx v8 brain data), industrial sensors (NASA C-MAPSS, Scania, Tennessee Eastman), financial markets (S&P 500), and ecological systems.

Installation

pip install wjpy

Quick Start

import numpy as np
from wjpy import (
    fast_spearman_matrix,
    weighted_jaccard,
    signed_weighted_jaccard,
    binary_jaccard,
    implementation_divergence,
)

# Compute Spearman correlation matrix from observation data
# data shape: (n_features, n_samples)
data_baseline = np.random.randn(50, 200)
data_regime = np.random.randn(50, 200)

corr_baseline = fast_spearman_matrix(data_baseline)
corr_regime = fast_spearman_matrix(data_regime)

# Compare networks
wj_uns = weighted_jaccard(corr_baseline, corr_regime)
wj_sgn = signed_weighted_jaccard(corr_baseline, corr_regime)
bj = binary_jaccard(corr_baseline, corr_regime, threshold=0.3)

print(f"Unsigned WJ: {wj_uns:.4f}")
print(f"Signed WJ:   {wj_sgn:.4f}")
print(f"Binary J:    {bj:.4f}")

# Decompose reorganization into magnitude vs sign components
divergence = implementation_divergence(corr_baseline, corr_regime)
print(f"Sign inversion %: {divergence['sign_inversion_pct']:.1f}")
print(f"Magnitude %:      {divergence['magnitude_change_pct']:.1f}")

Functions

Function Purpose
weighted_jaccard(corr_a, corr_b) Unsigned WJ (magnitude reorganization)
signed_weighted_jaccard(corr_a, corr_b) Signed WJ (magnitude + sign)
binary_jaccard(corr_a, corr_b, threshold) Topological reorganization at edge threshold
implementation_divergence(corr_a, corr_b) Decompose magnitude vs sign components
fast_spearman_matrix(data) Vectorized Spearman correlation matrix
fast_pearson_matrix(data) Vectorized Pearson correlation matrix
weighted_jaccard_chunked(vec_a, vec_b) Memory-efficient WJ for >10M-element vectors

Methodology References

  • Financial regime detection: Harbert, D.H. (2026). A Pairing-Family Decomposition of the Weighted Jaccard Index... Physica A (under review). Code: https://github.com/nwharbert8-ui/financial-wj-structural-regimes
  • Genomics application: Harbert, D.H. (2026). Sigma-1 and Sigma-2 receptors exhibit divergent genome-wide co-expression architectures... Frontiers in Pharmacology, Neuropharmacology (in press).
  • Industrial monitoring: Harbert, D.H. (2026). Weighted Jaccard decomposition detects sensor network reorganization preceding mechanical failure in turbofan engines, Scania trucks, and chemical processes. Mech. Syst. Signal Process. (under review).
  • Ecological tipping points: Harbert, D.H. (2026). Weighted Jaccard similarity reveals water quality parameter reorganization preceding trophic state transitions. Ecological Indicators (under review).
  • Pairing-family framework note: Layer 2H methodology, articulated 2026-04-29.

Premium Tier

The pairing-family decomposition implementations (Type 1 continuous-discrete, Type 2 sign-treatment, Type 5 local-global), full regime detection algorithms, macro-stress alignment utilities, and reference datasets per domain are available in a separate distribution wjpy-premium. Contact: Drake@innerarchitecturellc.com

License

MIT License (core). See LICENSE.

Author

Drake H. Harbert Inner Architecture LLC, Canton, OH ORCID: 0009-0007-7740-3616 Email: Drake@innerarchitecturellc.com

Citation

If you use wjpy in published work, please cite:

@software{harbert_wjpy_2026,
  author       = {Harbert, Drake H.},
  title        = {wjpy: Weighted Jaccard methodology for correlation network analysis},
  year         = 2026,
  publisher    = {Zenodo},
  doi          = {10.5281/zenodo.19025536},
  url          = {https://github.com/nwharbert8-ui/wjpy}
}

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

wjpy-0.1.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wjpy-0.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file wjpy-0.1.0.tar.gz.

File metadata

  • Download URL: wjpy-0.1.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for wjpy-0.1.0.tar.gz
Algorithm Hash digest
SHA256 eb53bc8968fc24000f0243f355141b4c17ed41285d204226ae2f5ef35125ba30
MD5 45f004bbc5c43e23f3cd4fbe56073b99
BLAKE2b-256 d40ff65c816780564078a1f4d476ee0baf5710612cb45ea52cf67a2f26c953ea

See more details on using hashes here.

File details

Details for the file wjpy-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wjpy-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.11

File hashes

Hashes for wjpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 07c788676d7a2d5d4dbecd3f4fc38fab9b2c564586e5faae029e7dbd0811e567
MD5 be50dcf9520d4ce15c138d99e509cdbd
BLAKE2b-256 f03434de272df21e58a31c038aa0c1432197d48fb182298ff28a6c856724a82f

See more details on using hashes here.

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