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.4.9-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0b5d99d1ac536c26eacd5a58589d3cabe2cc4fbc9ead9b8c7c7e87c86300e6a |
|
MD5 | 3bb4c1f3e2b75f263c1b801f0bf77694 |
|
BLAKE2b-256 | 7731e567553d87685ae2ed5d775ed5e78eaa6ffbc098c753d6996ad78878aecb |
Hashes for pyAgrum-0.13.4.9-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e5f0c989f9ba20ea48343b655b5260a5dbb14d7b6531ab87acf7bff78969c23 |
|
MD5 | 03618d9279a46e0f884ffe0f1e8eff08 |
|
BLAKE2b-256 | b93b1d29f1f1586116e9d625a8f25d64d6642ae55cbf2df2679b87916c504633 |
Hashes for pyAgrum-0.13.4.9-cp37-cp37m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6232e8ea39d5990e624679fe88a7eb4cc947f060b7b4dbebf96ba8080c255027 |
|
MD5 | 24aca4d37730858c6fc3db252b1bb60d |
|
BLAKE2b-256 | 84a7434a790717056019941a3bc7cf3f5a56ee8b559bb39602cb45316f4daa14 |
Hashes for pyAgrum-0.13.4.9-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6749a8741a5f29a11f15f962a1c7065c32fb05a355f8b77d25c96133d0477705 |
|
MD5 | 1b434d80d7032824f7ec4b7454256a22 |
|
BLAKE2b-256 | bd407287982eb0582df526e10b80da458a60545eb5e51a95de5fb0fe11ddbfe3 |
Hashes for pyAgrum-0.13.4.9-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d31d66aaea6f8832c2410b7ebb1dc2cc2479d586f516bd311effeab6d7748f74 |
|
MD5 | 117c44530804c47396fc043cded51a9b |
|
BLAKE2b-256 | e1146a39cc8aeb421864754afc0bb6dfc50e69e6fc402333b50b2ca67d18ecf4 |
Hashes for pyAgrum-0.13.4.9-cp36-cp36m-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 171ef7dc88c6ba0a04fc19df0edacac5fca0a529e56c4807f0329652ee1b0313 |
|
MD5 | 591755962272b57f295600ca777b76bc |
|
BLAKE2b-256 | de1bc033bafdbbc6f3c04ddec587fe0f13d945e3ac58b7bed38887ebaae6ffc9 |
Hashes for pyAgrum-0.13.4.9-cp35-cp35m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | decd6f13920c8ea72a4813288d674fbf0bbd9d3cae35f660ba21d8f27780e322 |
|
MD5 | 6500f992fdca770235fa4cff28703599 |
|
BLAKE2b-256 | 4da1b58c6411909ecad47ba2ef09e2712f5e9c0f2220e0f8b10ac644f7eb8826 |
Hashes for pyAgrum-0.13.4.9-cp35-cp35m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 782af406236d5d6c5299fc493edf91f3a17e4864328c1b711e9872ccdfba7412 |
|
MD5 | b2db8741370549688d44088f2f6303ee |
|
BLAKE2b-256 | a44fd1bcd11f4d74a497b4e5fdf3b0c86f1e3ffec53a350b7a74da2afce50f5c |
Hashes for pyAgrum-0.13.4.9-cp35-cp35m-macosx_10_6_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc3d68a858e3a00c5a9a8b980c309d68d71c66c4a7d0d50ef6bd04455ad35ade |
|
MD5 | 92358289d18653ba5e0792c8c2efabdb |
|
BLAKE2b-256 | e5452f2bc537c38f0bcde9a776cc69b034e64da81587718a9ccf92a6dc236e4a |
Hashes for pyAgrum-0.13.4.9-cp34-cp34m-macosx_10_6_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c27e71a5807618840a42a8f3529e3fc63c31e112e05066591083d6b3c5a4105 |
|
MD5 | d69e01761d151ee5ccae7ed6a2dc0c09 |
|
BLAKE2b-256 | 98c4481c24caefea45599f259c7fdba001d805924aa53e4ae8700c906a9389e0 |
Hashes for pyAgrum-0.13.4.9-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2de4b03fa413c2c1d669b0b07bda8fed96f40fcb1923733a74ddfc2fc694f25f |
|
MD5 | adc6cea7fdebbc324e6d5f8ab6ebe78a |
|
BLAKE2b-256 | 413bcbe42717bb3e543b2d0c1149a8903eb13ab7ad6b419021f694d9983758aa |
Hashes for pyAgrum-0.13.4.9-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19fb152cd957dca56222cffb9e583667ca2c09699bdf2bc61e83dd35b80eb3ae |
|
MD5 | 601fe483a94d11f6c343fbacd9e3669d |
|
BLAKE2b-256 | 8c62be4d127d097719592b2180bdc85e1069a1fda1fc09aa5903f9c7c5c4f749 |
Hashes for pyAgrum-0.13.4.9-cp27-cp27m-macosx_10_6_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08da54a8ccc3b3e3b24361216d9feae817535471bd65a156da43836276fe597a |
|
MD5 | eaadecabd6e12deaf8538bd9c70a9234 |
|
BLAKE2b-256 | e1408c1497200d5a44e69f51959e39f2a5f92002109b9e21ef4797efd72756a5 |