Skip to main content

BayNet

BayNet is a Python library for generating, sampling data from, comparing, and visualising Bayesian Networks.

Installation

pip install BayNet

Usage

Generate a 10-node Forest Fire DAG, and parameters, then sample data from it:

from baynet import DAG
dag = DAG.generate("forest fire", 10, seed=1) # Creates a DAG
dag.generate_discrete_parameters(alpha=5.0, min_levels=3, max_levels=5, seed=1) # Generates parameters
data = dag.sample(1_000) # Samples data, returning a pandas DataFrame

Generate a 5-node Barabasi-Albert (preferential attachment) graph and plot it:

from baynet import DAG
DAG.generate("barabasi albert", 5, seed=1).plot() # Saves 'DAG.png' in working directory

Example DAG.png

Generate two 5-node Erdos-Renyi DAGs and compare them:

from baynet import DAG, metrics
dag_1 = DAG.generate("erdos_renyi", 5,seed=1)
dag_2 = DAG.generate("erdos_renyi", 5)
print(metrics.shd(dag_1, dag_2)) # prints DAG SHD, in this case 3
print(metrics.shd(dag_1, dag_2, skeleton=True)) # prints skeleton SHD, in this case 3
dag_1.compare(dag_2).plot() # saves 'comparison.png' in working directory

Example comparison.png

Taking dag_1 to be the ground truth and dag_2 to be a structure learning result:

  • Dashed red arcs represent false negatives
  • Blue arcs are represent positives
  • Green arcs represent incorrectly directed arcs

Release files for BayNet 0.3.0

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

Source distribution (sdist)

Source distribution for BayNet 0.3.0
File Size Uploaded
BayNet-0.3.0.tar.gz 1.2 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for BayNet 0.3.0
File Interpreter ABI Platform
BayNet-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.5 MB

Release files / BayNet-0.3.0.tar.gz

Download URL BayNet-0.3.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
51d4a6d2460043ad24632808fa614f106d727ad55b3f18e618bc2927f358ab7c
BLAKE2b-256 checksum
How to use checksums
256d1439c08cd497f3affe4dc6ad6ae8321c35f8511cf3df17f045dffbeda583
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/46.1.1.post20200323 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.7

Release files / BayNet-0.3.0-py3-none-any.whl

Download URL BayNet-0.3.0-py3-none-any.whl
Size 1.3 MB
Tags Python 3
SHA-256 checksum
How to use checksums
308924f8d7aa339328ddbce90ea224bf2fa72acbcb3f4a0827b917e3b03504eb
BLAKE2b-256 checksum
How to use checksums
94db92ba29160830bfa070a6fd36f624a63b12b0981b97102c84498387d3ef55
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/46.1.1.post20200323 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.7.7

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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