Skip to main content

BANSHEE

Bayesian Networks (BNs) are probabilistic, graphical models for representing complex dependency structures. They have many applications in science and engineering. Their particularly powerful variant – Non-Parametric BNs – are implemented as a Matlab toolbox and an open-access scriptable code, in the form of a Python-based package.

This repository contains:

  • PyBanshee a Python-based open source of the MATLAB toolbox.

The supporting SoftwareX paper for PyBanhsee, PyBanshee version (1.0): A Python implementation of the MATLAB toolbox BANSHEE for Non-Parametric Bayesian Networks with updated features, can be found at https://doi.org/10.1016/j.softx.2022.101279

These codes are an update of the original version supporting SoftwareX paper: https://doi.org/10.1016/j.softx.2020.100588. The latest version of MATLAB BANSHEE (v1.3) supprting SoftwareX papper can be found at https://doi.org/10.1016/j.softx.2023.101479

The packages allows for quantifying the BN, validating the underlying assumptions of the model, visualizing the network and its corresponding rank correlation matrix, sampling and finally making inference with a BN based on existing or new evidence. MATLAB BANSHEE v1.3 and Py_BANSHEE have the same features.

PyBanshee

PyBanshee is a Python-based open source of the MATLAB toolbox BANSHEE.

Installation and updating

Use the package manager pip to install last stable version of the package.

pip install py-banshee

However, if you are looking for the latest updates, consider installation directly from sources.

git clone https://github.com/mike-mendoza/py_banshee.git
cd py_banshee
python setup.py install

Usage

Features:

  • py_banshee.rankcorr.bn_rankcorr --> Create a Bayesian Network rank correlation matrix
  • py_banshee.bn_plot.bn_visualize --> Visualize the structure of a defined Bayesian Network
  • py_banshee.copula_test.cvm_statistic --> Goodness-of-fit test for copulas
  • py_banshee.d_cal.gaussian_distance --> Measure the distance between Gaussian densities
  • py_banshee.sample_bn.generate_samples --> Make samples using the defined Bayesian Network
  • py_banshee.sample_bn.sample_base_conditioning --> Make samples based conditioning on intervals
  • py_banshee.prediction.inference --> Make predictions using a non-parametric Bayesian Network
  • py_banshee.prediction.conditional_margins_hist --> Visualize the un-conditional and conditional marginal histograms

Demo of some of the features:

from py_banshee.rankcorr import bn_rankcorr
from py_banshee.bn_plot import bn_visualize
from py_banshee.prediction import inference,conditional_margins_hist

#Defining the variables of the BN
names = ['V1','V2','V3']  #names of the variables (nodes)
N = len(names) 		      #number of nodes

#parametric distributions of the nodes
distributions = ['norm','genextreme','norm']	
parameters = [[100,23],[-0.15,130,50],[500,100]]

#Defining the structure of the BN
ParentCell = [None]*N
ParentCell[0] = []
ParentCell[1] = [0]
ParentCell[2] = [0,1]

#Defining the rank correlation matrix
RankCorr = [None]*N
RankCorr[0] = []
RankCorr[1] = [.1]
RankCorr[2] = [.41,-.25]

#Conditional rank correlation matrix
R = bn_rankcorr(ParentCell,RankCorr,var_names=names,is_data=False, plot=True)

#Plot of the Bayesian Network
bn_visualize(ParentCell,R,names,fig_name='BN_TEST')

# Inference
condition_nodes = [0] #conditionalized variables (node V1)
condition_values = [181] #conditionalized value (node V1)

F = inference(Nodes = condition_nodes,
              Values = condition_values,
              R=R,
              DATA=[],
              SampleSize=100000,
              empirical_data=False, 
              distributions=distributions,
              parameters=parameters,
              Output='full')

#Conditional and un-conditional histograms 
conditional_margins_hist(F,[],names,condition_nodes,
                         empirical_data = False,
                         distributions=distributions,
                         parameters=parameters)

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

GNU

Metadata

Release files for py-banshee 1.1.2

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

Source distribution (sdist)

Source distribution for py-banshee 1.1.2
File Size Uploaded Provenance
py_banshee-1.1.2.tar.gz 1.4 MB Without provenance Details

Release files / py_banshee-1.1.2.tar.gz

Download URL py_banshee-1.1.2.tar.gz
Size 1.4 MB
Tags Source
SHA-256 checksum
How to use checksums
f19b39f988d45fb04de371aafa272307d804a6abd95362e1ff3539248553a94e
BLAKE2b-256 checksum
How to use checksums
ba618d03700cce44332081c79b42f5d9f0783c0af8d9159f4e837126ff9e387f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.12.5

Security for py-banshee 1.1.2

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