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.tar.gz (217.8 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-cp313-cp313-win_amd64.whl (198.1 kB view details)

Uploaded CPython 3.13Windows x86-64

asbm-0.1.8-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-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (208.5 kB view details)

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

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

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

asbm-0.1.8-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-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (208.6 kB view details)

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

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

asbm-0.1.8-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-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-cp311-cp311-macosx_11_0_arm64.whl (174.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

asbm-0.1.8-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-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-cp310-cp310-macosx_11_0_arm64.whl (173.4 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: asbm-0.1.8.tar.gz
  • Upload date:
  • Size: 217.8 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.tar.gz
Algorithm Hash digest
SHA256 4904398ed274ef77ee2952788506f38c20dc540ea35a6074916f90d282c93431
MD5 83d55b4c6c17d227a74391f0c83a837f
BLAKE2b-256 d1195a19cfc57afa0f3888d86afda3d79c9547da806c114c2407b1279d54eb58

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.8-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 198.1 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-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 09c28babe8aae5a04e044f90d8470fdda3042562d0c21cf1a62b119563277baf
MD5 3ff50d714cb0b31afc4c244d261a23ef
BLAKE2b-256 492a8fce84c1da7b5d597e6a30d71fab5c396f5a5b329554edc0fbe95ad833a2

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.8-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3756da7a56cc9bdc14cef2bc4d38a13a1daaa7ca970bfd9f8385f6ad0a12eb8e
MD5 2e5c4f883c82bbf32cf0f78aea6fa132
BLAKE2b-256 18c274e512062e47c55b3d536342ff921ef44745a39c5482aa3278a8ca0741fd

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.8-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1fe74660872ce7ecbcb67420c4ec5fd52fe487609a53ff884b1e55849361b009
MD5 c29c398c0a129137a0a54209c8e40f42
BLAKE2b-256 60324f27ebc2b77cb8a8c17a454c8b3ede4b1b5c0f40d8f2a3199c9ad3934f1c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.8-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 176.2 kB
  • Tags: CPython 3.13, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for asbm-0.1.8-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8b17466dfa3d1a831155809a74e88686ae44fbdf30dd43dfb555f1ea27e54652
MD5 68ea88188a5d1f9ba00c8d1dfa6e19b7
BLAKE2b-256 e4c90dfc9035cbdcea4d8be289a8cbfeb8f463ff597bbbca8537b1cb5003173c

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.8-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 198.1 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-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 09ad3f1400fbeff3ccafd63d26f4be4b0e4d63a39a236e6745ffcaf1ef2401aa
MD5 55801b371e9692eda1d8c96898452be9
BLAKE2b-256 bd88dec28c6068d3da44988a6ab24deb4587c2527ccd306fc7036b53dfc01a7d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.8-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a27c791d35c41a6f0bdbb35f1fb7df5a0bf99696029bf219e0905383f89091d0
MD5 9d94007a4f6a5a7e75b4d25499275f87
BLAKE2b-256 82bd10903c62e18247448186f97014798afe4b5aeccca6356b13657e29a3739b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.8-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ead5ef39a2a3a0c819190a46f811521b719af0e6ff8afa2244d5339f1d5cc74a
MD5 76acd36a01c37a256201b0f8473a225e
BLAKE2b-256 abe249aaf10b10e790990cb49d01a2fe736c787f79f358a36cc3cba2fd960988

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.8-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 176.1 kB
  • Tags: CPython 3.12, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for asbm-0.1.8-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 450132853d31d9c403fe112da549b151886eeab40d9528ed81a8c8781c343a6b
MD5 6da604c9f5f77142c30a6726ed83c955
BLAKE2b-256 71d19e63e180bb9b4575983de16d30d08dee03ee2a7b8b616ee1a7f09e94de69

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.8-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-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0e8d564029c8942329e5445bee2b4cff4b8ae2366dafa857e78194eeb78eb536
MD5 a1c4d787ce0253cda92784360e1fd7e3
BLAKE2b-256 28cbbb5684bfc75a1893b2607c9cc8dbdc3d594694bd1f04d2343dc907f7625d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.8-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3432b2c4fab5dd117c490f4cd92e85effe1b2b6ab1a3efe6240c35d104b634b4
MD5 e84607cc369dca9db1e994d43e1c8c12
BLAKE2b-256 5cbd3c8f84e69121c622690fb607812f99fc991394817e1e2c3751f2491f9cd6

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.8-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 07e7ebc722a91bbe634ab4487bb88bce5e5342106355cb6f2c84eb122052f915
MD5 54ac7e52bebc114076f5804a8a41e193
BLAKE2b-256 adfc05cc1e9d52a909fd00075c7b2ecef63a8ecc6c0915d883c5446666f539b0

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.8-cp311-cp311-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 174.7 kB
  • Tags: CPython 3.11, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for asbm-0.1.8-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 19dace991017a3a4818e4e916f5966003a6149b420479feb1bb9ccb32acea416
MD5 f3affc1ffd3a325e1230960152f2e064
BLAKE2b-256 c520abe7ea50dd0a8951a6a00e7e5ae823f04ce7a15fe6e732ec858a856ba3bd

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.8-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-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 db823a94129f62cebee263e6884421e3bf7b24da8d5f79a43d3dae0ecccf6d06
MD5 20963ec6d39e76f9ec740db2c0aa4f12
BLAKE2b-256 9780323ec2035b55a3046c41983d50c1b8eee6a36439014741be41c0e4125828

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.8-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 56894cdc272e64f094e3a583d897f3af79aa672473def9c374ece50f631cd023
MD5 d2b52f406f75987023e9c4f101d8b0b0
BLAKE2b-256 ea1b0783d1c66b2381685a36914c154885df141ba5ac6325586b0fd988eb4385

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.8-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 403e8f2b18842af1f41a545dd9e5ead396c8d6f2bc54016356f777a87b3c4ba1
MD5 352ff22161b1b970d102bdd872f623db
BLAKE2b-256 b1a181daa9ea92f360e452685ea4c78afeb84fdf5691e16dda38e561aadef0a8

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.8-cp310-cp310-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 173.4 kB
  • Tags: CPython 3.10, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for asbm-0.1.8-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 043c225a245bb03385d19827812546dd90a2cda7d20ed5cf40565863d297b1ac
MD5 9cfeef1b362bed4c37bb7a106f1e990d
BLAKE2b-256 0d85bf47c74fda2bb47dcdb03a0b685e8e9b6f4e6967af82e7bedaf455f7e3fb

See more details on using hashes here.

Provenance

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