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

Uploaded CPython 3.13Windows x86-64

asbm-0.1.4.dev5-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.dev5-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.dev5-cp313-cp313-macosx_11_0_arm64.whl (174.4 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

asbm-0.1.4.dev5-cp312-cp312-win_amd64.whl (196.3 kB view details)

Uploaded CPython 3.12Windows x86-64

asbm-0.1.4.dev5-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.dev5-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.dev5-cp312-cp312-macosx_11_0_arm64.whl (174.3 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

asbm-0.1.4.dev5-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.dev5-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.dev5-cp311-cp311-macosx_11_0_arm64.whl (173.1 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

asbm-0.1.4.dev5-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.dev5-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.dev5-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.dev5.tar.gz.

File metadata

  • Download URL: asbm-0.1.4.dev5.tar.gz
  • Upload date:
  • Size: 656.3 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.dev5.tar.gz
Algorithm Hash digest
SHA256 87d2ed259b8bafa86d1a6a3c3f4657ba4bdf56dda56491337a307dddc3c239f8
MD5 48e0ab029fcff166c83a54577c454755
BLAKE2b-256 a3e69b534033a5d102b08ef3d8eb1d0ad4407e5deb99253d0cf8625b11ff0363

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.4.dev5-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.dev5-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 7a98a049dd04ddadefcb1b31789198faefc8d2b4a7951ce9d300c32328ea059e
MD5 5abd451a5f245123a8ad09f7c85853a4
BLAKE2b-256 c929489c23b11bd2adcdbb2be9c1f8bcfc1e2d3192e11c84eb8fd08fe652448f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 43169b1542cab1c6790c67b94f9425a6a6f789c23ad825bc385cbbafa91c302d
MD5 07801f15461de7e18212e6ade0382ca5
BLAKE2b-256 cf6ab946705e4af84c7c800381ff47fb51e76ddd869e5ce60c79e84238e17f8f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 280e5b18d284b8e6c0b0b59251edac56de1ff14e060ac8f0be90d22c873f0ec9
MD5 2f91458be241faf5dfefd6f0a9fb6591
BLAKE2b-256 1b1342d56fa77e9a2d409c3d573e44b410c92b1267fc4c6b191b5e58c34ebf7c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6ab90ad2b779267b3fb5008d671398def1f8dd9f92d9469914c5c7a25d281b4c
MD5 8f51f1a4933704c98f9bda0caad1d821
BLAKE2b-256 5299e367f838ddd3508b62581b4fb837faf6d15280fc05c21ae52ea1f1ad80d8

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.4.dev5-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 196.3 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.dev5-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a9f0e17a030d79e7e6877a07f7abef829ee6ddfb7baacc3eedfaaeb86a7f06b2
MD5 bb6b014bf17a6624299998f50a7f8091
BLAKE2b-256 0ccfb302b4776d5369d3131d7ee686e3823b964493111e35966e38f99db844f6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 bfd9ce0c06f41dd5f90ed3b8ad019d9ec3a2875152e5e33be39b640651f22fa7
MD5 64cb25a3d32ee9fbc85716c3a6e619e6
BLAKE2b-256 d65748616fe6f22e17ba7359ca0246bcee5f18806dbb32d70c2d06ad1f61791a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f14314371a4255c2468b831c53c36332acf58e6be6e6d06cd0d0be23f29229bb
MD5 590d58fcc3b02e5e05a4fea27fb7db5a
BLAKE2b-256 de266bd9ca0ff3d926c6e1a667eba9740a956a66366676c6c0c7176962f05006

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e18520d4b4785ea4aea74a9592e6e185d70f93230b8f06096407646e686b2680
MD5 c1abe647949e6c149a62fd46bdd9d5d2
BLAKE2b-256 0f29125c3bf1c833c706ab2338ac27400e9fa7fc161f6303f227ef8551345191

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.4.dev5-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.dev5-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 79efb90f39919b57c19d9c0ed15549f467bdea2519ce3a4274be8058e95ed3ba
MD5 9f596c53045cfef37bd2aa30b81891e4
BLAKE2b-256 9c5ea63509562a8bd1aec2a6e9603cdde429da34be7b54742d9699bb65ba56a4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1a28cc7e57546248a23a0aa5f9bfcccea48a3a1aecfb1d5b691044472c287181
MD5 db073ff1c81857fc4497dcb4643e58ff
BLAKE2b-256 03f0b55c04c472504ea3759999c8149c9c9ffa3cd4f06bb2975e62b2ebc58397

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c1dcc29f6070fbe0f5d0ea3155fb82c08d0f5ca6a8f3041223a36a904a6d10d7
MD5 8040a2e06fd0fd044a640bedefd1acb1
BLAKE2b-256 2808d4119f586077349bfe81054929ebad139b35f7c85401180c3273f1978d5b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0de31a8d4c100734ed270ab0492944fb0e9c089b191e15dd24d829154878030
MD5 b32d5f7d653ada565e25528a2c44ef80
BLAKE2b-256 70a83c39d39b9a1a9ea930f2d3c658991b25b63d5f3418727a397fff6fd3892b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.4.dev5-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.dev5-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f447e364c84e3fb39b1c53c5da6d71f9c06fd118978ce128880adcea8272ad85
MD5 ace85e73e4148cadfc8f72960837a2cb
BLAKE2b-256 4ea20200b4df9dfc74e78c1d9dee163153c58c61639e14452b15de2e1e0a0a43

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 819e3fd81928f6c2f8d206d14ba1ca42c3e31730627385614e8f8b77197ca904
MD5 d3c0abe961597c755a81403e3931a707
BLAKE2b-256 bf5d5667bc4190a9084ff90add87329209c0a9d2c530a3a08a512f8cf4b4eb4b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2bfd9f01e9f31f6690bfa310aa5ec979327552afff5bbcd3ecfb632920635061
MD5 a1f0aa4d27061637177706ed3709df18
BLAKE2b-256 fa85893b8d4b9c7e4be2e4695c0984b91bf9b12f164f9fbdb070cd8dd53c864b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.4.dev5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5d3e56e46558721653fa3446698baa1e8d369044a3b11d4fec53b4efeb24832e
MD5 b31457b40a674ade3a0499df1609da6e
BLAKE2b-256 dc2aa8986c2231659f8da02288229d8b965201e1e39105029dddb98d6b569985

See more details on using hashes here.

Provenance

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