Giter VIP home page Giter VIP logo

baynet's Introduction

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

baynet's People

Contributors

stoffle avatar bradley-butcher avatar

Stargazers

Roman avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.