Bayesian networks and other Probabilistic Graphical Models.

## pyAgrum

pyAgrum is a scientific C++ and Python library dedicated to Bayesian Networks and other Probabilistic Graphical Models. It provides a high-level interface to the part of aGrUM allowing to create, model, learn, use, calculate with and embed Bayesian Networks and other graphical models. Some specific (python and C++) codes are added in order to simplify and extend the aGrUM API.

## Example

import pyAgrum as gum

# Creating BayesNet with 4 variables
bn=gum.BayesNet('WaterSprinkler')
print(bn)

# Adding nodes the long way
print(c)

# Adding nodes the short way
s, r, w = [ bn.add(name, 2) for name in "srw" ]
print (s,r,w)
print (bn)

# Addings arcs c -> s, c -> r, s -> w, r -> w
print(bn)

# or, equivalenlty, creating the BN with 4 variables, and the arcs in one line
bn=gum.fastBN("w<-r<-c{Yes|No}->s->w")

# Filling CPTs
bn.cpt("c").fillWith([0.5,0.5])
bn.cpt("s")[0,:]=0.5 # equivalent to [0.5,0.5]
bn.cpt("s")[{"c":1}]=[0.9,0.1]
bn.cpt("w")[0,0,:] = [1, 0] # r=0,s=0
bn.cpt("w")[0,1,:] = [0.1, 0.9] # r=0,s=1
bn.cpt("w")[{"r":1,"s":0}] = [0.1, 0.9] # r=1,s=0
bn.cpt("w")[1,1,:] = [0.01, 0.99] # r=1,s=1
bn.cpt("r")[{"c":0}]=[0.8,0.2]
bn.cpt("r")[{"c":1}]=[0.2,0.8]

# Saving BN as a BIF file
gum.saveBN(bn,"WaterSprinkler.bif")

# Inference
ie=gum.LazyPropagation(bn)
ie.makeInference()
print (ie.posterior("w"))

ie.setEvidence({"s": 1, "c": 0})
ie.makeInference()
print(ie.posterior("w"))

# Adding soft and hard evidence
ie.setEvidence({"s": [0.5, 1], "c": 0})
ie.makeInference()
print(ie.posterior("w"))

Copyright (C) 2005,2023 by Pierre-Henri WUILLEMIN et Christophe GONZALES {prenom.nom}_at_lip6.fr

## Authors

• Pierre-Henri Wuillemin

• Christophe Gonzales

## Maintainers

• Lionel Torti

• Gaspard Ducamp

## Project details

### Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

### Built Distributions

pyAgrum-1.12.1-cp312-cp312-win_amd64.whl (2.6 MB view hashes)

Uploaded cp312

pyAgrum-1.12.1-cp312-cp312-manylinux2014_x86_64.whl (5.8 MB view hashes)

Uploaded cp312

pyAgrum-1.12.1-cp312-cp312-manylinux2014_aarch64.whl (5.4 MB view hashes)

Uploaded cp312

pyAgrum-1.12.1-cp312-cp312-macosx_11_0_arm64.whl (4.1 MB view hashes)

Uploaded cp312

pyAgrum-1.12.1-cp312-cp312-macosx_10_9_x86_64.whl (4.3 MB view hashes)

Uploaded cp312

pyAgrum-1.12.1-cp311-cp311-win_amd64.whl (2.6 MB view hashes)

Uploaded cp311

pyAgrum-1.12.1-cp311-cp311-manylinux2014_x86_64.whl (5.8 MB view hashes)

Uploaded cp311

pyAgrum-1.12.1-cp311-cp311-manylinux2014_aarch64.whl (5.4 MB view hashes)

Uploaded cp311

pyAgrum-1.12.1-cp311-cp311-macosx_11_0_arm64.whl (4.1 MB view hashes)

Uploaded cp311

pyAgrum-1.12.1-cp311-cp311-macosx_10_9_x86_64.whl (4.3 MB view hashes)

Uploaded cp311

pyAgrum-1.12.1-cp310-cp310-win_amd64.whl (2.6 MB view hashes)

Uploaded cp310

pyAgrum-1.12.1-cp310-cp310-manylinux2014_x86_64.whl (5.8 MB view hashes)

Uploaded cp310

pyAgrum-1.12.1-cp310-cp310-manylinux2014_aarch64.whl (5.4 MB view hashes)

Uploaded cp310

pyAgrum-1.12.1-cp310-cp310-macosx_11_0_arm64.whl (4.1 MB view hashes)

Uploaded cp310

pyAgrum-1.12.1-cp310-cp310-macosx_10_9_x86_64.whl (4.3 MB view hashes)

Uploaded cp310

pyAgrum-1.12.1-cp39-cp39-win_amd64.whl (2.6 MB view hashes)

Uploaded cp39

pyAgrum-1.12.1-cp39-cp39-manylinux2014_x86_64.whl (5.8 MB view hashes)

Uploaded cp39

pyAgrum-1.12.1-cp39-cp39-manylinux2014_aarch64.whl (5.4 MB view hashes)

Uploaded cp39

pyAgrum-1.12.1-cp39-cp39-macosx_11_0_arm64.whl (4.1 MB view hashes)

Uploaded cp39

pyAgrum-1.12.1-cp39-cp39-macosx_10_9_x86_64.whl (4.3 MB view hashes)

Uploaded cp39

pyAgrum-1.12.1-cp38-cp38-win_amd64.whl (2.6 MB view hashes)

Uploaded cp38

pyAgrum-1.12.1-cp38-cp38-manylinux2014_x86_64.whl (5.8 MB view hashes)

Uploaded cp38

pyAgrum-1.12.1-cp38-cp38-manylinux2014_aarch64.whl (5.4 MB view hashes)

Uploaded cp38

pyAgrum-1.12.1-cp38-cp38-macosx_11_0_arm64.whl (4.1 MB view hashes)

Uploaded cp38

pyAgrum-1.12.1-cp38-cp38-macosx_10_9_x86_64.whl (4.3 MB view hashes)

Uploaded cp38