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.
Maintainers
Lionel Torti
Project details
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
Built Distributions
Hashes for pyAgrum-0.13.2.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8da44156f95cf5e081dabe90a20358a0c1a70560e99d87fca74711079a2c8dc |
|
MD5 | e02a6f5cc8a957d7bd445d83b52738ae |
|
BLAKE2b-256 | 631cb93ae5ada6f1b588e0d49720dab8aa05ac7741a50e8a5a7803568d3feb84 |
Hashes for pyAgrum-0.13.2.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 439cbcfc6ebb3fe2e42a54735abceb26ef0b20b60bc00ffe1266811552cf0a86 |
|
MD5 | ada8cb743755f6c120afda61f42c016c |
|
BLAKE2b-256 | b17d0fb256b5561b5da9591c4394b8671d882823fef89f093e0b4e8330066821 |
Hashes for pyAgrum-0.13.2.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c02921b8b60c3022708f08d08f33d9d6acda3198a38900c5d863fbec461a0425 |
|
MD5 | c5d242adadc469a5c02688f1680b4982 |
|
BLAKE2b-256 | 1a1101ff9acda9267b53e52289a1b7d5ac2232037a5410e26606869bf85faccf |
Hashes for pyAgrum-0.13.2.1-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 16e5e4ec5d5defea1d98613b6fb5a59594b908307d37e172f7ca165433c2b12a |
|
MD5 | e88131f09af74b141d9d80949c9a2f7f |
|
BLAKE2b-256 | c53dcb5cfabd398dde15d2b730a1617f41a26d1e9bb22c6d17620aa1bc700aa7 |
Hashes for pyAgrum-0.13.2.1-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91f6f81888b29b3f9a3e5517d54d73c5c4de00edcfb296d6ca86f7cd90263bf4 |
|
MD5 | f6fc26cc3bff4d37afdff1ed581cec87 |
|
BLAKE2b-256 | 331d926daee13580600b459fa50be9512e567899348c01f3ca68609989aa0c2d |
Hashes for pyAgrum-0.13.2.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5e93bebcce53f5684bad527b2d7a23063a73826369c3bef21d2e17f5f5a449f |
|
MD5 | 68ce4a4781a3b04d9e50298d18bc1b0a |
|
BLAKE2b-256 | 9bf922d9b3db6ad162f6f82e8a6d586584fa7023160b85cae8db0ac91e85ffb1 |
Hashes for pyAgrum-0.13.2.1-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0dd726caf2fe25ae34e50bf3b5970ad03586e297bc3fa1ba7555719eeab7370 |
|
MD5 | 3fc21904ba611217899dbfbd03457c38 |
|
BLAKE2b-256 | 61878bd66f7f2b2338ed0488b16453c51cf5631b5003c41f25689e893f274203 |
Hashes for pyAgrum-0.13.2.1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9adfdc7e974b02d0d944265c4e41a2789b3d16bffc5c32645215d4186311b923 |
|
MD5 | 89bb191d42351094c24af52b0912e5b3 |
|
BLAKE2b-256 | 68c29b5564a2cad77cbc6b855181d54ea0bd5385ed1223a4a3f434685d527246 |
Hashes for pyAgrum-0.13.2.1-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e584cee6d359240fca0872f04ffbb5f9242a7a7db682e2ad467cd7261624b2be |
|
MD5 | b3108b722ae5e25a4e7932f04c1f0898 |
|
BLAKE2b-256 | 0423861ee31e2d84d855cd7eebb836ce1d609a4f32223c0e434d6decde418a7c |
Hashes for pyAgrum-0.13.2.1-cp33-cp33m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55384ea43e19c961796386bf2fb4927968a1ed9ce729fb463858e9167591b92e |
|
MD5 | 0b73a3260af1784d3b6c9415a8851678 |
|
BLAKE2b-256 | f0d761a2fe479cbe92ee4599bcb2f498b50b4199a391e1224f2b0d900d62a708 |
Hashes for pyAgrum-0.13.2.1-cp33-cp33m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21882a9970155cc027d7f929f73fccfa1e746df9de30ec1f85722554522109cd |
|
MD5 | a8c6482f31c3a74c9bfabf3b0042a5f5 |
|
BLAKE2b-256 | dd1b9f2c6696ed319e650ed9d9c3e175e155d6cc033cddae34c86fcefe11ad91 |
Hashes for pyAgrum-0.13.2.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81a39e4cff67df82473cc7ab98d2ecb903eece6eb9ee661c13a11097c5ad6cdf |
|
MD5 | ea6e3fe68921da453fbc44fbdd908133 |
|
BLAKE2b-256 | 11a43444e739b787c20d2f43fb2bde9f5dab4d80cf79fce027426e6a0544f835 |
Hashes for pyAgrum-0.13.2.1-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c585e60f4dc3467a30380e6c8a7eeb4ed31e711ed6c605a5869085a07ee2dcb |
|
MD5 | 951e9bd2af06d03bef0784230a62fa42 |
|
BLAKE2b-256 | bd610dc273cd07a060c76a6860e6869a4f12b6295b68ea9fd0bc44ae1cc21912 |
Hashes for pyAgrum-0.13.2.1-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4150fd750f771e1280203ddcf466b4208ef8d145fc3250dd9780f2d865d84d17 |
|
MD5 | 652b44e80bc6204e529290ab966874bf |
|
BLAKE2b-256 | 859a62821ae5aab3cc51c6e48628e0e96c1333c014b0a25e945de600dccb775a |
Hashes for pyAgrum-0.13.2.1-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17cd7326cd1247d9a2e5acd289d46f04794b6028b13d08a1e6e844d350e74641 |
|
MD5 | 4635b3d7c7386e658afc959aa0ade18e |
|
BLAKE2b-256 | 85038da5e492871a484cd790fa2984024b8fd514b37fe2954fd9c32e3448d8af |
Hashes for pyAgrum-0.13.2.1-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81b159d2d6023b27f3f8403980179a9203b3029bbf63489d039cdf3548471713 |
|
MD5 | 360a3c78d8f80673c585b6817a16205e |
|
BLAKE2b-256 | 58e7d8f359ccf3b238b0b90242f164ca77e0b5374150e9cc2a3e9037de44958c |
Hashes for pyAgrum-0.13.2.1-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8b99c151ac9b130c26312b39ade3645d89785e89bfbab046522f35265cfa2c3 |
|
MD5 | b4c16f0bc89a2b6d666ccb8fd914e3ff |
|
BLAKE2b-256 | f002f2376bd1780a1f20750fd4d7775cf6e24ca10dd706b88113152691176e42 |
Hashes for pyAgrum-0.13.2.1-cp27-cp27m-macosx_10_13_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bc67933b1c7eb2584ee9fd10bd601f23d302a3ffe5801255a21df585fb07acd |
|
MD5 | daa9c8c581f3f7ec71fa28ae8f8c4cfb |
|
BLAKE2b-256 | db42c77dc23620896a7ad9043779c0b8c0a1925a204ebe076df25bf6632bcb8f |