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.dev3.tar.gz (655.6 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.dev3-cp313-cp313-win_amd64.whl (196.3 kB view details)

Uploaded CPython 3.13Windows x86-64

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

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

asbm-0.1.4.dev3-cp313-cp313-macosx_11_0_arm64.whl (174.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

asbm-0.1.4.dev3-cp312-cp312-win_amd64.whl (196.2 kB view details)

Uploaded CPython 3.12Windows x86-64

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

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

asbm-0.1.4.dev3-cp312-cp312-macosx_11_0_arm64.whl (174.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

asbm-0.1.4.dev3-cp311-cp311-win_amd64.whl (192.5 kB view details)

Uploaded CPython 3.11Windows x86-64

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

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

asbm-0.1.4.dev3-cp311-cp311-macosx_11_0_arm64.whl (173.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

asbm-0.1.4.dev3-cp310-cp310-win_amd64.whl (190.9 kB view details)

Uploaded CPython 3.10Windows x86-64

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

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

asbm-0.1.4.dev3-cp310-cp310-macosx_11_0_arm64.whl (172.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: asbm-0.1.4.dev3.tar.gz
  • Upload date:
  • Size: 655.6 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.dev3.tar.gz
Algorithm Hash digest
SHA256 01275ff21be49b6a84ac0d0b8143dfabfa2d8c0063fb71be3ae96ddab039540e
MD5 0eadeac46a2a3220cf04b72167c51711
BLAKE2b-256 ed0972552886eb5db09176f5a9bace4111765f5c8ab442ae9d01f0cde56eafd9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.4.dev3-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 196.3 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.dev3-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 dc7a56d6e60ee93f70cad367abd04b1ddba029e12443b3966310a544184091f0
MD5 f5bf28546dc74dfcbbf1073d7268b581
BLAKE2b-256 b23a387f51ce906e853eff371bb4fa1e44ac76891f96723cc9ac02ed09686d39

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 21ad823f6ff6eeb4079a20f8e2ce9bee8e9e7a6794e0e6035a2c1ea5faa12c75
MD5 4bc3efa766c7868b9599ab2bf57c040f
BLAKE2b-256 f26431c261f09d3439a0ccf3fd94689b46288359e95da0339050be03e3d23d12

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 182381642efa16e4657502b8499a9484b818c8193f74918b2a61e288e72ec658
MD5 cdc3a5f49148ec70e85984506c0dc53b
BLAKE2b-256 19136e1108e65c0a5a43515a78137df77c6adb8facb3a4bfa547b6c962892ab3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 316007db3edb9c6b3cc125b500ef225b64e4cbc4c154125f85335152fde1163c
MD5 886c7c59c8bde1103c63d1c89e76186c
BLAKE2b-256 0d03f3e8a9dd982759bcc283fe68a3e46168a9a97db83d558c72873c1c548fa2

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.4.dev3-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 196.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.4.dev3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0f738e0c0c1b73cab41c30bb7dc99d992ee821482c8195badc02c484b0564ae9
MD5 e451f0a902be8f57fe38b9ff113a59e6
BLAKE2b-256 57f43532294ec59072bcc63481da5931e127770efce507b109bd2fbbf5da2948

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9fed2682de97e7a27a8ec701f1a0c8b0067fcb351eaad13d0dd3cca5d21c42dd
MD5 bb30634dff416f6c15d6d109ccee0db6
BLAKE2b-256 0a425b44065a360b802ba20a77486aa04e24e3ef87f2f81e85fff660b0095b12

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b29d1e769b485a3e965ba3c6bea93786d337f28bcff7be24b829a024eb011773
MD5 cefa13fbb415d7c870be5ff4ed6f330a
BLAKE2b-256 6d8f8707af05e9215f9560d1ca424d55ff6f8c7839104bf92f0aa3617344abec

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 daa78a1ce091638b762cceef1fd950dfb2b109e068da86d7ff0d4856eee6dedc
MD5 e9dbe86c80d53a57639742959dbca755
BLAKE2b-256 8240d781af347262bc3abbc96677a3fa4f1e5254e999e46ad75093a4de1253a9

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.4.dev3-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 192.5 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.dev3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 923d0926d0ee32fe043212267fdb04dc348568dbb815a97b275ade56ad7b510e
MD5 aa9aeeb72360421ddbd6ba986cd297b2
BLAKE2b-256 63a6f2f7cc603afc68151e5e68fd7d457f25deffdb2568a82740566fdb1adea3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 f0f13dd5c6b96ef0f04d7fe08e0f1e114c950f9d3c1f2bea30c09e39efff32b9
MD5 11d5b25ae7c8fafee6c8cd7f48bf99ab
BLAKE2b-256 f2a8602f640a2bd9e0279c742a35048a97b4b6aaf57d86cfc9c3adfafe18c69f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 47af5350a3d49f9d175252f57aa552ba5508c84c3661db4bd630f77dc62e78f9
MD5 99a0c14139601363c9c00c40db6571a7
BLAKE2b-256 f05a0217cb21f5ee724be7d24d3139b8b9cc71990ffe8374a3a3460b0fd64015

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ef549a9a280c4119757c169632873771a1607a412a4e7f944883e8cebac2ec48
MD5 b7b32ce6a3bcb3d33533c949b9b0ee5c
BLAKE2b-256 bc6b620de600c9a4c1ac474585e7c096a6f13eb1e24b63e5319f18b81e4e14eb

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.4.dev3-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 190.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.4.dev3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7dd758e631298fe421a29c71a084a4111cb6c1cf1e8482cf4dec6daa8199c366
MD5 649dfcbd955c8ea9fea1c6d8527fe656
BLAKE2b-256 6487052a07c14bad41a358f23eb406b5223f9dc0efb2ea57cb2f0e2755c86ee1

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 82e2ce7b423e6fbfb8dbc5f7f87700529c470aadb356f6ef2834ca96a05fe81c
MD5 480581edadb526cc19aeb87ecacb1a94
BLAKE2b-256 2910083fca3370da122b4d7ccd5416551696ecdd5470b05308513fd9dfaf4d48

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 937cb85dedff8dfc3e2117f6268b429bbe6c8574ed853edd6b1efca36fa394c3
MD5 aede3b71ca0ff1be340d1cab209b5e1b
BLAKE2b-256 0c4ab784c97bc9d10a08e34e9e8b77a78d3b0d603858af78521139aac8f2e03c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0684f559d6a10f68363ba573cae1962bc2ac5d6b6339308e5b8894cf4bc71fc6
MD5 597626bfe21c4e2ee555e8a79bcdb208
BLAKE2b-256 a03ecdabf7ccc3956a6e77b54260f712cda78ad80d4fe06069900c8a1a910381

See more details on using hashes here.

Provenance

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