Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

An implementation of bayesian cut methods

Project description

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


  • 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 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',

# Add the number of chains to run

# Run the Gibbs sampler

# 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

# Done

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
bayesian_cut-0.1.2b0-py3-none-any.whl (29.5 kB) Copy SHA256 hash SHA256 Wheel py3
bayesian_cut-0.1.2b0.tar.gz (25.1 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page