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.6.tar.gz (217.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.6-cp313-cp313-win_amd64.whl (198.4 kB view details)

Uploaded CPython 3.13Windows x86-64

asbm-0.1.6-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.6-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.6-cp313-cp313-macosx_11_0_arm64.whl (176.0 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

asbm-0.1.6-cp312-cp312-win_amd64.whl (198.4 kB view details)

Uploaded CPython 3.12Windows x86-64

asbm-0.1.6-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.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (208.5 kB view details)

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

asbm-0.1.6-cp312-cp312-macosx_11_0_arm64.whl (175.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

asbm-0.1.6-cp311-cp311-win_amd64.whl (194.6 kB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

asbm-0.1.6-cp310-cp310-win_amd64.whl (193.1 kB view details)

Uploaded CPython 3.10Windows x86-64

asbm-0.1.6-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.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (206.5 kB view details)

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

asbm-0.1.6-cp310-cp310-macosx_11_0_arm64.whl (173.3 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

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

File metadata

  • Download URL: asbm-0.1.6.tar.gz
  • Upload date:
  • Size: 217.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.6.tar.gz
Algorithm Hash digest
SHA256 35ce83e646f8298758a53deb941efb671f9c0f57d069a07e0f0cff13e93c9acd
MD5 1b5023b2176f998e8df23daae2e96df0
BLAKE2b-256 fd192cd4412a52309fde67c8c8529879b7d2fc7f9eb431e72358cf8410132500

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.6-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 198.4 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.6-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 1574aa964fc16f5439e1bd7b2f3836f620c3f9ef37a903f30a8fec7830e3619c
MD5 6d46ca6aaf893773ed9a540cc96b295a
BLAKE2b-256 971916f1f45313662eca147cc9424007c3d3c41ba790eff87ca6f925bc7d60d9

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.6-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e36018e0f98b53dfa17862bb53e9a8d58f9dd95918ef0a6cfe909e0525f4804d
MD5 6c4250e49066778d546129dad1fae806
BLAKE2b-256 1bd0b92ca9ad5ce0a01b283f26a3c607035b98600fec1692dced5b1b548860af

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.6-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 52214edb1ff9e21643070d884abd42aaa351a2eb0c62b79ee880846704081c65
MD5 b99099ba1a4b4175b1c5544241873a92
BLAKE2b-256 17c03d133086e37463a3ccf7fb8bc4a78f26ba636c1edf2a7085ef74f860e4f7

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.6-cp313-cp313-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 176.0 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.6-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 957f97c1b12299b9a5251579d602a693ea282b79df1cbbb3191094fd431f582d
MD5 84cf8f712fccd85d9ec36375e2ecc42a
BLAKE2b-256 e077697171d1db17c5051406ddf3e780e08caff0b8a5f6686d098832774489ac

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.6-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 198.4 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.6-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4cd56830879f15fdbfac0ccf59f4bce49457a40baca065730991024d78e3bd45
MD5 3176a1839ff9f6b8b10f79657bb4be0b
BLAKE2b-256 8112cac8857528d883d846b58cd1177d5dff57643e6e85ab12a89c11401c4427

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.6-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e023fc4331c3e67312bab64dfe41a732095b60543bfb10bb3650965590a981c7
MD5 f393a5ae4af2130cf874c155cc041b40
BLAKE2b-256 cc37dbccdd420f4d4c2486ba0702880f4b5d38d6dcf30cc548da0121ffbf8e54

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.6-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6461467996876b9e1b5bb530a7a0ba9147ae6c97f57f01c7a4280405bd366be0
MD5 66ae30591fb4f4d7bc4698b606f1cff8
BLAKE2b-256 53fea1e7bfd357846d94dbf3418d889b5c159db685453dd2dca6dcfc35c09e6f

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.6-cp312-cp312-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 175.9 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.6-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 689aca9e0b62e9e394a1f8da22795416ff15aa46d4a97608e43edf2501ec0094
MD5 71773ae97d5b44d591bc12c6d7c9a230
BLAKE2b-256 de0c386400088be341af03260c3db3240c6d149f797ceca08f2282dac77ade1b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.6-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 194.6 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.6-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 d36f93929a38f5d5c41c493755a71bf4ff2f149568d657194354a982a3bfdc5a
MD5 0d4355f9fa28acb3cb0fe41ea1eb3087
BLAKE2b-256 e174740724657af6164af3b0fb3a854fd71b3887f309486388df75041ce70bed

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.6-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7b53aeedc6ed6aea993312adff47bbc67c021c6b37e20af932b60c9f536fe51a
MD5 58ec78aabdf83f19f8009e1c45a22dbf
BLAKE2b-256 92bf4f50152c8502a820fa57f8f66f4b7cbbaec52f0ce4d7ee62e01347fb011c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.6-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bc6a46167dc925957a32b08e8bfe1712c7139ba66c3db06ebc02d9528bc617d6
MD5 44464307c2552055330a30b3ccdb5167
BLAKE2b-256 84c476ff80b819f576294565efc67534cec2f9230a3c8305abd6366e0abfb515

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.6-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.6-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5683f8034511126a7520031f4dc8b4c350da7d6ace99b3ad252f15f46ea24e6e
MD5 e2185130ecaad960ab7f706b5cb8f7fd
BLAKE2b-256 0d2d6dc25bbed1e68054bec554f134d144e434e3cd65e0535507759d0d049526

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.6-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 193.1 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.6-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b508cd05adea431bac18496e8e863df9ec7b8a5651123fe8195cb8e3f3d40cb7
MD5 0b574679abd019cca9e8f9a471b7c3ef
BLAKE2b-256 8708b01d1d9f1719a975d3a6a8164f2d4444b7cf333a65f1f4e4b48eef1ec51c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.6-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 110396546940070128bcca399787db0445c55a406ff4a8392d06284d7cbeb865
MD5 927eaa924b9f21084b271b7def1b430a
BLAKE2b-256 d5e603a552ba790cbdbb1778ea133d3ada9efc43eef0b30b10103475de980539

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.6-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 96ccab786d54c69959ac1adea987fc6fdc5bb1743f6f3e7a04079bc80155084e
MD5 a2181c88d8d07482bd37cc03b3fbfcde
BLAKE2b-256 e8928fb0e057694c9e35c5caf9faf58156ee389ec981d0e3caa09642f12dfe50

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.6-cp310-cp310-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 173.3 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.6-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9f2a0a130624e826f05ff2a9812acbe0197f88a9e3d15f7a14497eac4967229b
MD5 dab91197b102fb34577d0051884a8678
BLAKE2b-256 651c7cb61a5ad75041bd02df49ac474c540f3c5d104d5fbdcc9ba4e317977dba

See more details on using hashes here.

Provenance

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