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 by Pierre-Henri WUILLEMIN et Christophe GONZALES {prenom.nom}_at_lip6.fr

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

Authors

  • Pierre-Henri Wuillemin
  • Christophe Gonzales

Maintainers

  • Lionel Torti

Release history Release notifications

History Node

0.13.2.1

History Node

0.13.1.2

History Node

0.13.1.1

History Node

0.13.0.1

This version
History Node

0.12.1.0

History Node

0.12.0.9.1

History Node

0.12.0.3

History Node

0.12.0.1

History Node

0.12.0

History Node

0.11.2

History Node

0.11.1.9

History Node

0.10.4.3

History Node

0.10.3.4

History Node

0.10.1.1

History Node

0.10.0.1

History Node

0.9.3.7

History Node

0.9.3.6

History Node

0.9.3.5

History Node

0.9.3.4

Download files

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

Filename, size & hash SHA256 hash help File type Python version Upload date
pyAgrum-0.12.1.0-cp27-cp27m-macosx_10_13_intel.whl (6.3 MB) Copy SHA256 hash SHA256 Wheel cp27 Apr 9, 2018
pyAgrum-0.12.1.0-cp27-cp27m-manylinux1_i686.whl (16.8 MB) Copy SHA256 hash SHA256 Wheel cp27 Apr 9, 2018
pyAgrum-0.12.1.0-cp27-cp27m-manylinux1_x86_64.whl (17.0 MB) Copy SHA256 hash SHA256 Wheel cp27 Apr 9, 2018
pyAgrum-0.12.1.0-cp27-cp27mu-manylinux1_i686.whl (16.8 MB) Copy SHA256 hash SHA256 Wheel cp27 Apr 9, 2018
pyAgrum-0.12.1.0-cp27-cp27mu-manylinux1_x86_64.whl (17.0 MB) Copy SHA256 hash SHA256 Wheel cp27 Apr 9, 2018
pyAgrum-0.12.1.0-cp27-cp27m-win32.whl (1.5 MB) Copy SHA256 hash SHA256 Wheel cp27 Apr 9, 2018
pyAgrum-0.12.1.0-cp27-cp27m-win_amd64.whl (2.1 MB) Copy SHA256 hash SHA256 Wheel cp27 Apr 9, 2018
pyAgrum-0.12.1.0-cp33-cp33m-manylinux1_i686.whl (16.8 MB) Copy SHA256 hash SHA256 Wheel cp33 Apr 9, 2018
pyAgrum-0.12.1.0-cp33-cp33m-manylinux1_x86_64.whl (17.0 MB) Copy SHA256 hash SHA256 Wheel cp33 Apr 9, 2018
pyAgrum-0.12.1.0-cp34-cp34m-manylinux1_i686.whl (16.8 MB) Copy SHA256 hash SHA256 Wheel cp34 Apr 9, 2018
pyAgrum-0.12.1.0-cp34-cp34m-manylinux1_x86_64.whl (17.0 MB) Copy SHA256 hash SHA256 Wheel cp34 Apr 9, 2018
pyAgrum-0.12.1.0-cp35-cp35m-manylinux1_i686.whl (16.8 MB) Copy SHA256 hash SHA256 Wheel cp35 Apr 9, 2018
pyAgrum-0.12.1.0-cp35-cp35m-manylinux1_x86_64.whl (17.0 MB) Copy SHA256 hash SHA256 Wheel cp35 Apr 9, 2018
pyAgrum-0.12.1.0-cp36-cp36m-macosx_10_13_x86_64.whl (6.3 MB) Copy SHA256 hash SHA256 Wheel cp36 Apr 9, 2018
pyAgrum-0.12.1.0-cp36-cp36m-manylinux1_i686.whl (16.8 MB) Copy SHA256 hash SHA256 Wheel cp36 Apr 9, 2018
pyAgrum-0.12.1.0-cp36-cp36m-manylinux1_x86_64.whl (17.0 MB) Copy SHA256 hash SHA256 Wheel cp36 Apr 9, 2018
pyAgrum-0.12.1.0-cp36-cp36m-win32.whl (1.5 MB) Copy SHA256 hash SHA256 Wheel cp36 Apr 9, 2018
pyAgrum-0.12.1.0-cp36-cp36m-win_amd64.whl (2.1 MB) Copy SHA256 hash SHA256 Wheel cp36 Apr 9, 2018

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page