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.9.dev2.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.9.dev2-cp313-cp313-win_amd64.whl (198.2 kB view details)

Uploaded CPython 3.13Windows x86-64

asbm-0.1.9.dev2-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.9.dev2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (208.6 kB view details)

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

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

Uploaded CPython 3.13macOS 11.0+ ARM64

asbm-0.1.9.dev2-cp312-cp312-win_amd64.whl (198.2 kB view details)

Uploaded CPython 3.12Windows x86-64

asbm-0.1.9.dev2-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.9.dev2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (208.7 kB view details)

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

asbm-0.1.9.dev2-cp312-cp312-macosx_11_0_arm64.whl (176.2 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

asbm-0.1.9.dev2-cp311-cp311-win_amd64.whl (194.4 kB view details)

Uploaded CPython 3.11Windows x86-64

asbm-0.1.9.dev2-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.9.dev2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (207.5 kB view details)

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

asbm-0.1.9.dev2-cp311-cp311-macosx_11_0_arm64.whl (174.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

asbm-0.1.9.dev2-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.9.dev2-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.9.dev2-cp310-cp310-macosx_11_0_arm64.whl (173.5 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

File details

Details for the file asbm-0.1.9.dev2.tar.gz.

File metadata

  • Download URL: asbm-0.1.9.dev2.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.9.dev2.tar.gz
Algorithm Hash digest
SHA256 54aeb9010eaea93d96605ffed217de3c0219a4d62c6be89670172c5763f838e5
MD5 65d63bd4b187c410bc05da0712cad861
BLAKE2b-256 85788bda27b0931260b3548c6c7ede2e415390445433faecb799738bc71f9965

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.9.dev2-cp313-cp313-win_amd64.whl
  • Upload date:
  • Size: 198.2 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.9.dev2-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 aa623d1dc3594fd2ea303eb6a7c4abf7d8819978fe06b8e97e0c79c1c48b047a
MD5 683ab18e544262d5caa6a740202d65a6
BLAKE2b-256 6096af531fc80ecdaac6ff06bb29cb8f29eeac818845aded7b399d311a3baa8b

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 478aaae73483dd41f047845db763775815547d2a18dca5ff81a0940dd5ec85dc
MD5 5b0ec50cf8c043550fe716032ead001c
BLAKE2b-256 802702f3a2b8deb30ffe3a1008b7ed411ef02a00b40566de206c170ac9bb6768

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bf62e7dcee5d1f473c67ada2daf3444f4c65b1a5b5a0f29e67a0337f4dc568d1
MD5 11032ac3fd18f2f051b38ebbf2d52f30
BLAKE2b-256 a930eb3103482712a579df958ce98c8ec71273f4334afb8ba42fb9e4d589d01c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 feebd622048cc20e6562b817dc9d0e304aa633a1a30bccef4b2645fbbc1cf298
MD5 294448213ebb365d3966b846ac85eac3
BLAKE2b-256 867296f70ef9061b33f17787dc3c5cf3d7c9921bb66e56a4c816618f23088723

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.9.dev2-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 198.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.9.dev2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7fecb5f52382bec448c046f40d8fc60755f2afdc0e80b9afe4683252dea34f04
MD5 23de59b810e6fa8f64cb4ff0fdfb773d
BLAKE2b-256 11411851c12df89c13d0fb8933c20c72cbc13cd4a2e8b53df96f61da5c8d8f17

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 956f1e18bd9e37ab95d1f2f8a7e71d7be59e032d10cefa83a034daf8ccaa8f10
MD5 347811d80a3a0cf6368fb174863378fe
BLAKE2b-256 230dab1328d7963f3e0bcb8eaa9ec4078a50bd158e351fad14a095818b3050ca

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9a94144a6c8c16a259aaed115c6fb16e04a17658d87157cbcda90231c498187f
MD5 9a5eab7609614c4111b1834835204e24
BLAKE2b-256 cf6f172c83578202861aca65f7761d5ef5901c8f81ce5fa0bb7c4d57aa856fd8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed9437dac3b2f8129fa40ee894f7554ecf0ad0c6c18704610fb8fb5d55e4db95
MD5 e70b7579deb38837e3ed261cf40d90b6
BLAKE2b-256 3795ee04648566159e37cc398cd97b680cd64cd31f8ce4c9fbe9d9b703ee5975

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.9.dev2-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 194.4 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.9.dev2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 aaec7bd698734def67b71eb6708319cbd39ab2055b6cd7571f90018162310004
MD5 9935f1b1efc0686d35e716589e6ebdc3
BLAKE2b-256 090a821c27e7dcb04e4f0069939b89f6eb5e1c18e7865841104543e6e062af5c

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ef382a0ae84ffc5833981ceb30e0f58cfdd1a44f4b4a64e06e23dd21b9fde0bf
MD5 587cef50501086d261ae992461897641
BLAKE2b-256 522c8761a9e33a66390557ad39a8530e2e36e59553d27f4e173b0ced9c52deef

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 455a753165b27808e55f8d766dea3535f5829d31d15c2ee5bcb52eef5b6138bb
MD5 cc564dd811c7f26575e322273386513c
BLAKE2b-256 8a7111ad1e297a2e5198b2c740de80b1cbbb9a3d6430eb0a92c5995988931c44

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4fad397ca8650399779acd5372b39585df963304f2eb7a4e48c59dc4713bae8b
MD5 a54fe27540d601f8b30a65963ea2f7cc
BLAKE2b-256 22f1e3eda042da49f448c56927721d69f121999c5ba4a398b2bce45ef72de4cf

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.9.dev2-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.9.dev2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7e751282f225ad40fec28e0ec3830f32bccf1e4b7c2147abebebf3bb3277637b
MD5 2ea47b728e0603a737e635c43e6312f3
BLAKE2b-256 aa4fa16a9da40570331b10842232817588ec2885bad3d6641597cf02faf0bbcc

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 43be500fc02eb1669554805fb17109d14baad32ad361a57950aa278ed712963f
MD5 81be396967031e35adfbcf7f5047402b
BLAKE2b-256 7e9e4bdec015d2503ffb772bbfffe502338fa00add357bd3ee4d7ad8b5601e26

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 28b6ad20d0a82b5a5f1e11b8aef593f4b9b0e30945715b35a69971ef27ce91eb
MD5 8a9764b9815586659cabb9b8652bba6c
BLAKE2b-256 29e2ca4449c02d04c40ade7f86b186a1358563b7636956cad2301caf99d5b4ea

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.9.dev2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c64315c48ed35cfca9e5d1e998fc95018539567db5e6708b2799ca2efd221279
MD5 f2b9eb954c0878147cb7621d8e489889
BLAKE2b-256 bf6f3317946cde9689d903491d05451dc1940e57106a7b624ca8d4c43ddaa9ce

See more details on using hashes here.

Provenance

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