Skip to main content

pyAgrum is a Python wrapper for the C++ aGrUM library

Project description

pyAgrum

pyAgrum is a Python wrapper for the Agrum library, to make flexible and scalable probabilistic graphical models for inference and diagnosis.

Sample code:

import pyAgrum as gum

bn=gum.BayesNet('WaterSprinkler')
print(bn)

Example

import pyAgrum as gum

# Creating BayesNet with 4 variables
bn=gum.BayesNet('WaterSprinkler')
print(bn)
# Adding nodes the long way
c=bn.add(gum.LabelizedVariable('c','cloudy ?',2))
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
bn.addArc(c,s)
for link in [(c,r),(s,w),(r,w)]:
  bn.addArc(*link)
print(bn)
# 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)[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)[1,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")
# Loading BN from a BIF file
bn2=gum.loadBN("WaterSprinkler.bif")
# Inference
ie=gum.LazyPropagation(bn)
ie.makeInference()
print (ie.posterior(w))
# Adding evidence
ie.setEvidence({'s': 1, 'c': 0})
ie.makeInference()
print(ie.posterior(w))
ie.setEvidence({'s': [0, 1], 'c': [1, 0]})
ie.makeInference()
print(ie.posterior(w))

LICENSE

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

The aGrUM/pyAgrum library and all its derivatives are distributed under the LGPL3 license, see https://www.gnu.org/licenses/lgpl-3.0.en.html.

Authors

  • Pierre-Henri Wuillemin
  • Christophe Gonzales

Maintainers

  • Lionel Torti
  • Gaspard Ducamp

Download files

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

Files for pyagrum, version 0.16.0
Filename, size File type Python version Upload date Hashes
Filename, size pyAgrum-0.16.0-cp27-cp27m-macosx_10_6_x86_64.whl (3.4 MB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp27-cp27m-manylinux1_i686.whl (4.1 MB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp27-cp27m-manylinux1_x86_64.whl (4.4 MB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp27-cp27mu-manylinux1_i686.whl (4.1 MB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp27-cp27mu-manylinux1_x86_64.whl (4.4 MB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp27-cp27m-win32.whl (1.7 MB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp27-cp27m-win_amd64.whl (2.4 MB) File type Wheel Python version cp27 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp34-cp34m-macosx_10_6_x86_64.whl (3.4 MB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp34-cp34m-manylinux1_i686.whl (4.2 MB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp34-cp34m-manylinux1_x86_64.whl (4.4 MB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp34-cp34m-win32.whl (1.7 MB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp34-cp34m-win_amd64.whl (2.4 MB) File type Wheel Python version cp34 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp35-cp35m-macosx_10_6_x86_64.whl (3.4 MB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp35-cp35m-manylinux1_i686.whl (4.2 MB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp35-cp35m-manylinux1_x86_64.whl (4.4 MB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp35-cp35m-win32.whl (1.7 MB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp35-cp35m-win_amd64.whl (2.4 MB) File type Wheel Python version cp35 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp36-cp36m-macosx_10_7_x86_64.whl (3.4 MB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp36-cp36m-manylinux1_i686.whl (4.2 MB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp36-cp36m-manylinux1_x86_64.whl (4.4 MB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp36-cp36m-win32.whl (1.7 MB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp36-cp36m-win_amd64.whl (2.4 MB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp37-cp37m-macosx_10_7_x86_64.whl (3.4 MB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp37-cp37m-manylinux1_i686.whl (4.2 MB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp37-cp37m-manylinux1_x86_64.whl (4.4 MB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp37-cp37m-win32.whl (1.8 MB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size pyAgrum-0.16.0-cp37-cp37m-win_amd64.whl (2.5 MB) File type Wheel Python version cp37 Upload date Hashes View hashes

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