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

Uploaded CPython 3.13Windows x86-64

asbm-0.1.7-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.7-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.7-cp313-cp313-macosx_11_0_arm64.whl (176.1 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

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

Uploaded CPython 3.12Windows x86-64

asbm-0.1.7-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.7-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.7-cp312-cp312-macosx_11_0_arm64.whl (176.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

File metadata

  • Download URL: asbm-0.1.7.tar.gz
  • Upload date:
  • Size: 217.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.7.tar.gz
Algorithm Hash digest
SHA256 1ee8276905873701c394e03f3f8642d444a2a517f4cf776931418de531d6a33e
MD5 b413ee67adf6b08eddd16e1fdb6bdbfe
BLAKE2b-256 591f9d525dbabcb336ef641343a431eb7fbee02429413fdc680eac6cd4fcc017

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.7-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.7-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 ab80f463ec2092ff6c609e24f25de6db3aae395833fd7ac7cda51ea3cab1aa49
MD5 71cf5ba81645065cb20ff374dc22debb
BLAKE2b-256 46345d5a96506470550b734f2ca2179a0d37cffc87929d3a16fffc26a9b51eae

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp313-cp313-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 add6302a069da063c179b733042c77889d9e0354ea78ebbeb1859a03762db37c
MD5 cdd597eff2a484fbc3b27fbbcb8f5311
BLAKE2b-256 ec3a556864ba3fc5dadbfc434cd698d03a2628fb5acd6fc3b7c1bc07fdb4fe13

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp313-cp313-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 80414a0e4c1c17cc2a79bf446f24d49dd533377b3f9a10bc90006c645f964860
MD5 ff392fb2599e5d437bd30d17a731f47e
BLAKE2b-256 9ca1e5bbae120f112c8716e8c6b40287c90fb32a6fac69bafee33a7cf706a417

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fa425c6e6d15245b36388b6d528915419232e0ce4d2a544f05c0da83a7e43e7a
MD5 8899610a352b5302cfb308af85197330
BLAKE2b-256 6ed92f12504a86e5dde3d3d43647cff7c8d99d49c5260fa080f117ad6fb41978

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.7-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.7-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 38c05d254002356a13d0f00d3e90207fd082dd43e46acdc8bba43e024490ae99
MD5 46d7db7dc99da0ff8aadd9971b2d2ba6
BLAKE2b-256 2b8bbd85ff3580389ed61f114ca3725ef7f0f6349b8a7730040d3067b253a1c8

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp312-cp312-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 4ad7fd20e22f568a671fdf4c0ecc9a0b7fec05f51d453de9c4ec3db9d13c976e
MD5 93c5fbbf78b9d1305b4bfafb70802184
BLAKE2b-256 b38624dc228fef3e77dfbbb77d363553f015b55713bf64d9315486a1ce0dbaae

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 207190d8884299004924db1522e0fc58535c555108989b37d54c389d014b82c5
MD5 8ad69b39c2bf34aa22e8cccc17d64a4d
BLAKE2b-256 a8a66306fdb3cd832f29380bca70dabe138cd7c8f4f2dd72bc44339298f6649d

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2793f5c1e278a6535868c4ac597f98110fa810c23e716f336887da165d0f9b97
MD5 dce685afc4d80f5dacf7ffe7ddff0e84
BLAKE2b-256 a849d3f1fa1592cd6af7caf154f538856a7c2eb472736b674b8506cd1761772a

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.7-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.7-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3bb746e7b6bbd9ae48bb92406ac0c7ff8a452b2e13c50a80966643e8f5f07ef8
MD5 82dd8db73183dc8280fce779ece0db3d
BLAKE2b-256 598d2f8b629c6242bf55d486e301cb382b5e9e79aecc907a69307be0a610d132

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp311-cp311-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1b44928c4d665223d2ce278cb33d629da9e42f009ff02f0907535f4a36aea76a
MD5 c39148a58a53f6704eae3c51eb682d72
BLAKE2b-256 a24a3dabaa577621bce220e3984c5fca948e95ad216a8505f9a16b229ff6311a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 51f6657c8bb45f08688ff6e8506168182612ee952d02fcfa5de3b470456528c6
MD5 e550b8846ba0e3a503d339db7f85162c
BLAKE2b-256 a1f8f23e781b6f48166988050a582ea7fdecfe82877ef1beee892af5823d70e3

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0bb823dcea0b469ec6bb280b08c9086ddb23be6cb4bc924f300dbbcb1022293d
MD5 54db1461783763f9760d89a7d25d893d
BLAKE2b-256 999c42aecceff36eb87b287ceb2b8afaf43a3d6604b182a73b88cb8959460632

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: asbm-0.1.7-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.7-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 7a3babd4e975c0c1c4d98f87f4c3fae514d1c29321cc89cf42d8febf1c1caf18
MD5 679e13fd43c2cbc578a99822d33a6367
BLAKE2b-256 2ca6c5dfafed89c13c342d908ca70176b77e379bc7eab63b1da0f77a078a3b1f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp310-cp310-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c947dd33b6007a4dcf31ac1fd2dd55f0c30f5958c76b4af11e2f5af407add2ec
MD5 65bac50d46ee21d3f00bf35a1c5aab51
BLAKE2b-256 e1fd2c6d36a77449e716e692d8c50f4c32ad249e77c3e24c049e375f920f8a35

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7d3bfd6e191793722a9f89a64a00cdcf4eadbaed12681d7807a0a5eb6e6b8e59
MD5 5d3fad43c194d8ceaa0248e7dd6f71ce
BLAKE2b-256 929716e6bea7e3f795f28a98b71f9ef6e720be6cf2fc054322a625ea854fbc9a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for asbm-0.1.7-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ddc607aa5141b83a030a0e9d53010733f78efa71c839c943024d1b2f27d01273
MD5 321184b2ecfb3fa8a8d7ad0c701619f9
BLAKE2b-256 ed00921d45fe1770b0f36ff848dc8fe250746a29f697c0160d56bfd98b7f7f30

See more details on using hashes here.

Provenance

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