Skip to main content

Find group structures in networks

Project description

asbm

Documentation Status PyPI version PyPI platforms

Infer network groups and properties with assortative stochastic block models

Maximilian Jerdee

This Python package uses Bayesian inference to find meaningful groupings of nodes in networks.

We implement a general assortative SBM that unifies the standard SBM and the planted partition model under a common framework. Its parameters directly measure the violation of each model's assumptions: the assortative preference ρ_in/ρ_out captures departure from in/out symmetry, while per-group variation coefficients v_in and v_out measure heterogeneity across groups. The standard SBM, planted partition model, and the Zhang–Peixoto hybrid emerge as special cases, enabling exact Bayesian model comparison between them.

For each model, the package includes algorithms to:

  • Find consensus estimates of the group structure
  • Infer global network parameters (assortativity, group sizes)
  • Score held-out edges via posterior predictive likelihood

Installation

Implementations are available for Python, R, and Julia.

Python

pip install asbm

Or build locally from the repository root:

pip install .

R

install.packages("asbm", repos = "https://maxjerdee.r-universe.dev")

Julia

using Pkg
Pkg.add(url="https://github.com/maxjerdee/asbm", subdir="bindings/julia")

Building from source requires CMake and a C++17 compiler. Run Pkg.build("ASBM") after installation to compile the native library.

Quickstart

Python

import asbm
import networkx as nx

G = nx.read_gml("examples/data/dolphins.gml", label="id")

config = asbm.Config(
    model="general_asbm",
    degree_correction=True,
)

result = asbm.fit(config, G)

print(result.mdl_partition)
print(result.mdl_value)
print(result.consensus_partition())

To score held-out edges:

G_train = nx.read_gml("examples/data/train.gml")
G_test  = nx.read_gml("examples/data/test.gml")

result = asbm.fit(asbm.Config(model="general_asbm"), G_train)
score  = result.log_posterior_predictive(G_test)

R

library(asbm)
library(igraph)

G <- read_graph("examples/data/dolphins.gml", format = "gml")

result <- fit(G,
              model             = "general_asbm",
              degree_correction = TRUE,
              num_chains        = 4,
              samples_per_chain = 100,
              seed              = 42)

print(result$mdl_value)
print(result$mdl_partition)
print(result$consensus_partition)

Julia

using ASBM, Graphs

g = cycle_graph(62)  # or load via GraphIO

result = fit(g;
    model             = "general_asbm",
    degree_correction = true,
    num_chains        = 4,
    samples_per_chain = 100,
    seed              = 42)

println(result.mdl_value)
println(result.mdl_partition)
println(result.consensus_partition)

For the full API, including posterior predictive evaluation and the samples schema, see the package documentation.

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

asbm-0.1.8.dev2.tar.gz (217.7 kB view details)

Uploaded Source

Built Distributions

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

asbm-0.1.8.dev2-cp313-cp313-win_amd64.whl (198.2 kB view details)

Uploaded CPython 3.13Windows x86-64

asbm-0.1.8.dev2-cp313-cp313-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.13musllinux: musl 1.2+ x86-64

asbm-0.1.8.dev2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (208.6 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

asbm-0.1.8.dev2-cp313-cp313-macosx_11_0_arm64.whl (176.2 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

asbm-0.1.8.dev2-cp312-cp312-win_amd64.whl (198.2 kB view details)

Uploaded CPython 3.12Windows x86-64

asbm-0.1.8.dev2-cp312-cp312-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12musllinux: musl 1.2+ x86-64

asbm-0.1.8.dev2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (208.7 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

asbm-0.1.8.dev2-cp312-cp312-macosx_11_0_arm64.whl (176.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

asbm-0.1.8.dev2-cp311-cp311-win_amd64.whl (194.3 kB view details)

Uploaded CPython 3.11Windows x86-64

asbm-0.1.8.dev2-cp311-cp311-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11musllinux: musl 1.2+ x86-64

asbm-0.1.8.dev2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (207.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

asbm-0.1.8.dev2-cp311-cp311-macosx_11_0_arm64.whl (174.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

asbm-0.1.8.dev2-cp310-cp310-win_amd64.whl (192.9 kB view details)

Uploaded CPython 3.10Windows x86-64

asbm-0.1.8.dev2-cp310-cp310-musllinux_1_2_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10musllinux: musl 1.2+ x86-64

asbm-0.1.8.dev2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (206.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

asbm-0.1.8.dev2-cp310-cp310-macosx_11_0_arm64.whl (173.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file asbm-0.1.8.dev2.tar.gz.

File metadata

  • Download URL: asbm-0.1.8.dev2.tar.gz
  • Upload date:
  • Size: 217.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for asbm-0.1.8.dev2.tar.gz
Algorithm Hash digest
SHA256 2828c80cddeb96fd06c5ca1c62e3051782d4027360eae4597f335e023b00eb71
MD5 1d63d3233a0977db3d51cbde5faffc74
BLAKE2b-256 d779ba89dd68e1fd68ec3da4d7be77af49f29312f44bc77857baafcb700e8b0b

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2.tar.gz:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: asbm-0.1.8.dev2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 198.2 kB
  • Tags: CPython 3.13, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for asbm-0.1.8.dev2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ee879e41cd98388d469a986fa952264c189ad54ed53e85804520d70aef3e5ec0
MD5 ac6af80a0a252d2c1f68f552e07d49cb
BLAKE2b-256 1deece596d5fb785f17309890ca20cd7eea328b245b537945340ad9a6af3c2d4

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp313-cp313-win_amd64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7bb7da48d1f53af3bedbd880a70e219795eeef06a85ca117f94ed66ceb9ebdf1
MD5 08697dc19a9381595aa67d332198a827
BLAKE2b-256 fe0e38e5a54b8a550c4b97eb4fbbe9dfca7d9a33bef447b073da0ca78d11721e

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp313-cp313-musllinux_1_2_x86_64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d74fbc1c109c81eb516525fe57aecb8f179b47b17444a402f0537d9590177c7
MD5 0479edeffa1e3fdea7b4f54ca1fb36a5
BLAKE2b-256 b7bb3a110d1d50d6c09752c7096b09221663f1ce1e0a2691e126a385879b8d31

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fa783567f6cd04e8222a10e7b32b38bbe56c962dace76884254c63bfc63378a8
MD5 e042e75ca6f73c2f50650c3465afc8e3
BLAKE2b-256 588a2d9d4c49b3813d9424fb42c7a2762858284884152db9c8c1ce2c8087b9c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp313-cp313-macosx_11_0_arm64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: asbm-0.1.8.dev2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 198.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for asbm-0.1.8.dev2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 935e4ac6cae6d0c9f216d2fa6abaad16f475e7dac9f9fc6523a3120d0636bf44
MD5 9d6adc528cc54221b47ded57246d9be0
BLAKE2b-256 d1b9ff0181a371f269363f12dc1570151d227eddde04f605906b64d8eeecde7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp312-cp312-win_amd64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 6a270585ed067b646e89627227b774a9256c7664e383a1abad9fb126a4779d93
MD5 227f022934b40d86598baad34ac02e34
BLAKE2b-256 947b2500d4e83db1fd8c9f5ed247fa35bdc7dd08d27b9fd145864a47ae7eaa08

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp312-cp312-musllinux_1_2_x86_64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0a6ae845a891d49abf50c80446a230510463eaf4070301e2437ccedacede39ed
MD5 3a1dc87d2114a8c8983e3e4be0ac456f
BLAKE2b-256 cd3ae62c5171f38435a54458d52d2b6f086dfba8ec119e9525040ee6fcd11a13

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5e0b85b85c8992851fa6dc95c1f9889bcca38a7ac534d187cc20b8aa770af628
MD5 624dd6c19d076efe0ca0ecbf19a30d36
BLAKE2b-256 f1cce49bd68784df76ef56a336752384892b29bd1162a53aa4e10e8228ce41a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: asbm-0.1.8.dev2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 194.3 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for asbm-0.1.8.dev2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 7cb5da8bbe7cefe5d51c576f218ad658dd8b245c79dd3624007cc2a11840a873
MD5 2147f09f18ab71b4c2def42859027812
BLAKE2b-256 2e1695dbc21608cb7f19bc5cb9e7ef1674b90d7d906b6d0fa118ede29c2f7b42

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp311-cp311-win_amd64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 cc1f12a1beef507cd8ad61ad05dc02e3f8c20971ebfaaeeebc859e2824578ea4
MD5 10bf53d9e58e2dc2f32ac433e533ddfb
BLAKE2b-256 d1059a52a67f635901c5778e82eee531ead4b39e32097be0b98cb684269679e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp311-cp311-musllinux_1_2_x86_64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d106eae4f66c96d659b48ccfdd36b7033344ca934242aaa578a6da354ae2cace
MD5 a4fc0d7ad4643e048c45f3982fc86e03
BLAKE2b-256 29a49fcd0bd32c91b8dac91209a1b74c2fe4924c4750c811fc06581d6d59f832

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 658990e0e035b500e95f7024e904f5103299061edbff1c2ccdd2ff1d70077f2a
MD5 4d29746d726a4db8aebef1704b9d0e0a
BLAKE2b-256 f51db49e3260fcef927cb7fa627f3e60f29a6d764d875ff26ed6452bc53a3a28

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: asbm-0.1.8.dev2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 192.9 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for asbm-0.1.8.dev2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b7719f9540fd7eb727021a7b923dddbefe716893d2502f55f4af421207053ed1
MD5 9732992d1b8befb078ae72f9d869891a
BLAKE2b-256 286742a3c01025ff8458770c8f9d13683b6199fbfba390034cc6d3e02729a8bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp310-cp310-win_amd64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4f21de6ea5434fea28a16294a5bb13bd61d173dda8a154d71d0fbf38f3ec1559
MD5 9398b566c033301b3da3ebd400ccb1c0
BLAKE2b-256 739d0f3f3190af240c813741227cfb66d53cf74eef2fd7f9947566dd31c3f766

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp310-cp310-musllinux_1_2_x86_64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ddcdccc3c18f003f0c3bfaa15a91920a1f9a9664568b7e8ba855f28898a93102
MD5 213f31c94a7de313721a0aa3a679e65b
BLAKE2b-256 3b6a0410456f3f7063a43e8ecc00ab7ad0bd78ade276e15b923de3da5c73e024

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file asbm-0.1.8.dev2-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for asbm-0.1.8.dev2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b6ed92819c465083a8062ff2fbe1c03472135d0083c47366d7ae0d8e572cc63a
MD5 49119a98d8cc15ab8f90c74c7158fd68
BLAKE2b-256 8c51fad59c860e9536711305f458650b9284814373e04bb7e8930e79c55da7c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.8.dev2-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on maxjerdee/asbm

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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