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 | RSS feed

Download files

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

Source Distributions

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

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyAgrum-0.11.1.9-cp36-cp36m-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.6mWindows x86-64

pyAgrum-0.11.1.9-cp36-cp36m-win32.whl (1.5 MB view details)

Uploaded CPython 3.6mWindows x86

pyAgrum-0.11.1.9-cp36-cp36m-macosx_10_12_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.6mmacOS 10.12+ x86-64

pyAgrum-0.11.1.9-cp35-cp35m-win_amd64.whl (2.1 MB view details)

Uploaded CPython 3.5mWindows x86-64

pyAgrum-0.11.1.9-cp35-cp35m-win32.whl (1.5 MB view details)

Uploaded CPython 3.5mWindows x86

pyAgrum-0.11.1.9-cp35-cp35m-macosx_10_7_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.5mmacOS 10.7+ x86-64

pyAgrum-0.11.1.9-cp27-cp27m-win_amd64.whl (2.1 MB view details)

Uploaded CPython 2.7mWindows x86-64

pyAgrum-0.11.1.9-cp27-cp27m-win32.whl (1.5 MB view details)

Uploaded CPython 2.7mWindows x86

pyAgrum-0.11.1.9-cp27-cp27m-macosx_10_12_intel.whl (5.4 MB view details)

Uploaded CPython 2.7mmacOS 10.12+ Intel (x86-64, i386)

File details

Details for the file pyAgrum-0.11.1.9-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum-0.11.1.9-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 d5c018acc46354e43615ea2853692196e25d5ce8bbc2b6a03bf7e485ab1f36a1
MD5 15cf3f5f75403e0c1bf3d3417f9bcfdc
BLAKE2b-256 652a41c7884f4b6f84880349e426282424ca827bf2b0ff3d10f456c9e4ee4f2c

See more details on using hashes here.

File details

Details for the file pyAgrum-0.11.1.9-cp36-cp36m-win32.whl.

File metadata

File hashes

Hashes for pyAgrum-0.11.1.9-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 06ea2633d4dc622914b079cb43c5cc8c0bd96bdf7e9bdc10103a8d56aa4364b8
MD5 4431becaddde83780aede1d413d2337a
BLAKE2b-256 3d56b105424528711399d524707373016fb5fa6213775d2269d061474e9edf60

See more details on using hashes here.

File details

Details for the file pyAgrum-0.11.1.9-cp36-cp36m-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum-0.11.1.9-cp36-cp36m-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4c121cb17f5ac4a6daf4edfaac50ccea1806cb6383077013abd063e3f8f82f69
MD5 b1145af4861254b7a5965956f0a64ff2
BLAKE2b-256 18a61181a92e1cd84fd60ac7a240fb845aec0951f47d148c6278944b604c6789

See more details on using hashes here.

File details

Details for the file pyAgrum-0.11.1.9-cp35-cp35m-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum-0.11.1.9-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 9b92d0e6034567b02f54a6ac7d2870ba8199304e0bf22091896dae00a282c1e7
MD5 c7eb272d95db1c0c6fde686a18019f37
BLAKE2b-256 fcbb9418f2297f4ca135170b767b7920f4c6df7f7886e12a239a515a64baa590

See more details on using hashes here.

File details

Details for the file pyAgrum-0.11.1.9-cp35-cp35m-win32.whl.

File metadata

File hashes

Hashes for pyAgrum-0.11.1.9-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 2dd5625ce50a90c6f9bad3904dd56220caf519b27061be4eb0fb2d51dc66da89
MD5 a5038ec821618cabfdddbd6538c414eb
BLAKE2b-256 a012b62f6eee8234cc68d520749e0cd3c3edad0140972762edbf4568fccce379

See more details on using hashes here.

File details

Details for the file pyAgrum-0.11.1.9-cp35-cp35m-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum-0.11.1.9-cp35-cp35m-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 b09378a3ea61a59dfc21857f077d711e5214f32c66c5ea9695891930634ca614
MD5 ceb3d94bfd5ac4165cbeee80785299e6
BLAKE2b-256 ef7c20b37622f02dbd9f525a79e5fabffe4bec1573a60a11c80163d4d5d0e1df

See more details on using hashes here.

File details

Details for the file pyAgrum-0.11.1.9-cp27-cp27m-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum-0.11.1.9-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 a680b2193520c0b01ed5c3b2cb26ff1fd5fd9c630eb4ca261ee2944fb9771f4b
MD5 a4e7491525840c1de1b8d57ebcd904e3
BLAKE2b-256 f0589a43100bc03099ada428851a6a78b43cadbe074d82d9fb75bda8d8e0855f

See more details on using hashes here.

File details

Details for the file pyAgrum-0.11.1.9-cp27-cp27m-win32.whl.

File metadata

File hashes

Hashes for pyAgrum-0.11.1.9-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 af2547e4a6c1b225510e50b683f71f1944fbcbe7a26b204de323d42a7ad791cc
MD5 d357c5153d8b3e8ca32068d059889b5a
BLAKE2b-256 43936214666fbc53225980b58acbb6366473ab1a57cc2f375f3d6c8f937ed3cc

See more details on using hashes here.

File details

Details for the file pyAgrum-0.11.1.9-cp27-cp27m-macosx_10_12_intel.whl.

File metadata

File hashes

Hashes for pyAgrum-0.11.1.9-cp27-cp27m-macosx_10_12_intel.whl
Algorithm Hash digest
SHA256 1590db09ae4189b8db653015f481a362bc7a0b5872930769526ffa0019d44156
MD5 1641fe3bcef44f8ceddf058cbf9d0c56
BLAKE2b-256 1913329d5bcd82a4129781aff259b672bc4bb00da165fb8923ed58bbba997c6a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page