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.4.dev7.tar.gz (238.5 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.4.dev7-cp313-cp313-win_amd64.whl (197.5 kB view details)

Uploaded CPython 3.13Windows x86-64

asbm-0.1.4.dev7-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.4.dev7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (208.0 kB view details)

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

asbm-0.1.4.dev7-cp313-cp313-macosx_11_0_arm64.whl (175.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

asbm-0.1.4.dev7-cp312-cp312-win_amd64.whl (197.5 kB view details)

Uploaded CPython 3.12Windows x86-64

asbm-0.1.4.dev7-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.4.dev7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (207.9 kB view details)

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

asbm-0.1.4.dev7-cp312-cp312-macosx_11_0_arm64.whl (175.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

asbm-0.1.4.dev7-cp311-cp311-win_amd64.whl (193.8 kB view details)

Uploaded CPython 3.11Windows x86-64

asbm-0.1.4.dev7-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.4.dev7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (207.0 kB view details)

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

asbm-0.1.4.dev7-cp311-cp311-macosx_11_0_arm64.whl (174.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

asbm-0.1.4.dev7-cp310-cp310-win_amd64.whl (192.2 kB view details)

Uploaded CPython 3.10Windows x86-64

asbm-0.1.4.dev7-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.4.dev7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (205.8 kB view details)

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

asbm-0.1.4.dev7-cp310-cp310-macosx_11_0_arm64.whl (172.8 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file asbm-0.1.4.dev7.tar.gz.

File metadata

  • Download URL: asbm-0.1.4.dev7.tar.gz
  • Upload date:
  • Size: 238.5 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.4.dev7.tar.gz
Algorithm Hash digest
SHA256 9c3fecd2d43cc59dc1710c0622c0b0aeb591169ec4a66891b474bed8cf292043
MD5 130a7a87a941e46209bab185291a0e7a
BLAKE2b-256 5afc7090e6e426a9f0302e06ca274e57e3cde053d1bd33be161509e5d1bcb1fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7.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.4.dev7-cp313-cp313-win_amd64.whl.

File metadata

  • Download URL: asbm-0.1.4.dev7-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 197.5 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.4.dev7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 e1de08a56f0de6e4f7f09d01fb894de50a6ef46a971676cdbc396ead58671202
MD5 5f28a4ab03850831024b0c3d6dfd4860
BLAKE2b-256 e66554bc10495eb610e03172efd4ab0a4e78ac0a4c8452499837311e1f0bca51

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp313-cp313-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a5ef5b003652d373dd45406c6856ad21a5a91fdfb932dbd0cc6068a1affdc9b2
MD5 2f514312e71826e57eb71ce29292af45
BLAKE2b-256 1acb8cf90049f68f20f1e1a75c65a4f62960e9085cd2ba3f5ea29062655bc03c

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7df195a39bd12c3a460146bbf0a4125e8bfc765e7d53ec371c11ff292d87700d
MD5 9329feaf6b8608bd668190c3ac8ed0b5
BLAKE2b-256 ac882ffa646b265b9c8b1cafb07d03bba5559cf8674c35aae6a4a9f17de558f8

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8dbdf73fe40655dc2662d51d94fee25677bcbe1332f1db70d29785e079fd72ff
MD5 e0f21b541c11e7a1ea2014d48c4fb028
BLAKE2b-256 4c536a6f9a34e98533ceae8b60e75064bdf1df7cef9b8abf906fe5a1e50c83d1

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: asbm-0.1.4.dev7-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 197.5 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.4.dev7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b6b86a97ff22ab9eb4277bdd07653ae7915b41e83f9817ddfc19e1c8277b3b90
MD5 ed6d2d15103a5c50b88424151248eb89
BLAKE2b-256 18a391001b88222d2ff0c36463417de124cde5d7e6c480bf7c1a9fc1a74db47f

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp312-cp312-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b9069384ec38aa6c1df1e20f1599cdb15a682a41b5616f60b3af9751618857ed
MD5 46b26a55b23c03b4069174abfaa23709
BLAKE2b-256 8bdaf6c8ae055e4a4a741d77a6e32de7deb0ab1a43afafd5b62576605d484c32

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 af6e559fb2e0e1714d1da0a0e105058a034f2780b31150ad1113564a7150f223
MD5 2e245ae3d191515d106dbc49c47e6d09
BLAKE2b-256 dd46d830add2c4577cb5a1f1e49fdb591fbcd47847dd60f2f1d14a61d9c957f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f9db540a5bc45da583f732fb8b732a524aba4499e5047fbee11d6f562ca656e6
MD5 4bd3b2367e7135a209028ad71ae846c0
BLAKE2b-256 dc4bb9a88f85e1542f9b505d913f3a6a760f3419a49b2cc3e1028d0a0ccd9b01

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: asbm-0.1.4.dev7-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 193.8 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.4.dev7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 a485504a53927573f0c9f2712a657fdab392b6b684e8571c5aaacd6ccb1dc94c
MD5 93bbf6d98e8acd53e417c805983aa59a
BLAKE2b-256 124258bf397c5f08cfbefaa3d0f3135090e6524fd6b274d7899cf5160e0f21ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp311-cp311-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 410b09a9497ac0d7a71a63d6227ab9bf1f309388caabcda60119b9531d930dc6
MD5 86ec1148f8934d0bdf764cb52b0a1742
BLAKE2b-256 70f57706a12a2e3033155712484c641d4e6c2418bdc298b92872825d824f3438

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 5a37c40c9dfda05d3a6e67ed6f55d3bf3d63e61604cfeae6165c2da25fa70a0f
MD5 7bc1d713c974511e75a2a24b22ab7683
BLAKE2b-256 13ef1bd082bfcb82a754d393a752de0e28e4caea4b9c38fde39c8cdffd05fffd

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 28b9f3e277739ca67b26f09eb897de6b0ce68a9479e7dca2fb69bb41449936cd
MD5 1a489ed7d67d3d56552814529b597479
BLAKE2b-256 c9ccb621e9c1c3fa919395ab153820c4bb1c0bca83307ddc8a0799d2f253c75b

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: asbm-0.1.4.dev7-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 192.2 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.4.dev7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 35ed914cd5fa697c5c5a319e9729cbeaa5decce132e3b27e31babad7e4268d5a
MD5 5b86a5a331ba3ad74bc6a224a21c97d0
BLAKE2b-256 fa10dfff83d5a3db668613b216fad15a4afe092fc8937834a783fdea4449c1fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp310-cp310-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 083fd6a676798f609b5bc6046d4a1ef859adf039765b125b10be5aae344324b5
MD5 4a105cf378b0832c901ad8002eb0e8bb
BLAKE2b-256 2d7cd0e392e16ef2663405ace07e37230e86307d677a2a4056b4d147219b41f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 620f9f7fe8d4a7c1b051e74d7f7c3f1aabc12b4d7b01e3d6621597b075f1e933
MD5 3deb916551840fc738ea2047d6a85185
BLAKE2b-256 45794576a066e4876a82dbec972715d3d316d881416f630f6059a62075b656d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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.4.dev7-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for asbm-0.1.4.dev7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af21598c85159224e1edcab7d52b0b93349b541007914dd8b73dcdc9ebcb539e
MD5 9fa5c8828ed0613e71df106ea259f0d6
BLAKE2b-256 966c54b400100336876b9af643fdbe371852ad9f6bf48dad839d761c022604cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for asbm-0.1.4.dev7-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