Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Pypi Version License Build Status

The Bayesian Cut Python package provides an easy to use API for the straight-forward application of Bayesian network cuts using a full Bayesian inference framework based on the Gibbs-Sampler using the degree corrected Stochastic Blockmodel (dc-SBM) or the Bayesian Cut (BC). Furthermore it provides modularity, ratio-cut and norm cut based spectral network cut methods. It also provides a rich visualization library that allow an easy analysis of posterior solution landscapes and network cuts obtained by the various methods.

Jupyter Notebooks with examples on how to use the package can be found at https://github.com/DTUComputeCognitiveSystems/bayesian_cut/tree/master/examples

Installation

  • Install the package for Python3 using the following command. Some dependencies might require an upgrade (scikit-learn, numpy and scipy).
    $ pip install bayesian_cut
  • Now you can import the bayesian cut class by typing
    from bayesian_cut.cuts import Model

Quick Start

Use the bayesian_cut package for performing graph cuts

# Load the package
from bayesian_cut.data.load import load_data
from bayesian_cut.cuts.bayesian_models import Model

# Load an example network
network_name = 'karate'
X, Y = load_data(network=network_name, labels=True, remove_disconnected=True)

# Set the parameters for the model
n_samples_per_chain = 75
n_chains = 15
C = 2
model_params = {
    'alpha_in': 1e-2,
    'beta_in': 1e-2,
    'alpha_out': 1e-2,
    'beta_out': 1e-2,
    'b': 1,
    'gamma': 3
}

# Define the model
BC = Model('ShiftedApproximateBayesianCommunityDetection',
            X,
            model_params,
            Y=Y,
            C=C,
            block_sampling=False,
            marginalize_phi=True
            )

# Add the number of chains to run
BC.add_chains(number_of_chains=n_chains)

# Run the Gibbs sampler
BC.run_chains(n_samples=n_samples_per_chain,
              n_prior_updates=20,
              verbose=2,
              save_all_samples=False,
              parallel=True
              )

# Obtain the cut with the highest log-likelihood
graph_cut_z_vector = BC.get_best_chain().max_log_lik_z_

# Plot the cut as an adjacency matrix
from bayesian_cut.utils import utils
utils.cluster_plot(BC)

# Done

Metadata

Release files for bayesian-cut 0.1.2b0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bayesian-cut 0.1.2b0
File Size Uploaded Provenance
bayesian_cut-0.1.2b0.tar.gz 25.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for bayesian-cut 0.1.2b0
File Interpreter ABI Platform
bayesian_cut-0.1.2b0-py3-none-any.whl Python 3 none any Details

Total release size: 54.6 kB

Release files / bayesian_cut-0.1.2b0.tar.gz

Download URL bayesian_cut-0.1.2b0.tar.gz
Size 25.1 kB
Tags Source
SHA-256 checksum
How to use checksums
45eebf057ade356b71bcb401aff9a4ce8f8f8a73b7c16f471489146040bce5e2
BLAKE2b-256 checksum
How to use checksums
8df8c8782d08f573699b184dd8f581ed4eb593e1d6290c67a8deace245ebc273
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.6.8

Release files / bayesian_cut-0.1.2b0-py3-none-any.whl

Download URL bayesian_cut-0.1.2b0-py3-none-any.whl
Size 29.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5fa5c7616a411bdb89b09ddebdf487c754f96be40a04534b5ab6baf5ddc68379
BLAKE2b-256 checksum
How to use checksums
8e968f429a2111ae2e097d6e0b7c998185d5074f1010e348d9da181de7270b30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.31.1 CPython/3.6.8

Security for bayesian-cut 0.1.2b0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page