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.12.1.0-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49c9181e837ea5fd0fd7f12d288bb558ae2eb458b920ed596de307eeba0fca3a |
|
MD5 | f1f802a391772a1e954113b92e9c88f0 |
|
BLAKE2b-256 | 197492e23c918190819ab9388a80a57e18bdba740fade87f24b39f9d410e4905 |
Hashes for pyAgrum-0.12.1.0-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f953088f31443f12b60822b9a5f4f1874a16e8169fbec09f184c3d69afc976f |
|
MD5 | bd678de9fedbe1b4f0cc3923370c0da6 |
|
BLAKE2b-256 | 51f2d99bf8e57b1d47a97e1f6dcea61af6386aaa6b3948071008b727db65d529 |
Hashes for pyAgrum-0.12.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | daf8bcc82866de5432531eec375cc8b675f29877ac9fc7d09ef2996cfaddd35f |
|
MD5 | cd986bcecfa53ff9a85f0b18fd3cfa5f |
|
BLAKE2b-256 | 9ec6e332a1aef7fed7b859d5658bf29e66ba4785a56d6873306aec8a2aa53221 |
Hashes for pyAgrum-0.12.1.0-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 065c793ddb276d6fb24bf833d44ef853a529f8b5fca8eddd0202b30173e71c24 |
|
MD5 | a179527da75c6dbf1c534021924ca8db |
|
BLAKE2b-256 | 36f0a236bd1a44c0fb33a9896e526848fed540a64f80bd6da5a1006bc468b9c2 |
Hashes for pyAgrum-0.12.1.0-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d614deb89bd22487ec512586e5ad595e35f6204f4c6800d9fb26926625388dde |
|
MD5 | e0b0a610a6eb5c9b30a290e33c93a9ea |
|
BLAKE2b-256 | 31a8a6431268c1f9c3457ed4428a4013ef2ba3393f9d81e1e199425f402e1780 |
Hashes for pyAgrum-0.12.1.0-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc02e7f701a9a017aafe81ad72fd8bec373c9cda341ccdc7e6d65c0e46e7daa6 |
|
MD5 | 8d3544de1251d2fd1007cefc27baac8c |
|
BLAKE2b-256 | 232dea6312b0514bf954d78607dae57f7326c37f395b06267659007102910b3e |
Hashes for pyAgrum-0.12.1.0-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cac18a33c00dd5a1facb9593fa5b9c7630389c5ebc9b82871fd716245b03cca |
|
MD5 | 8c8c0290987cce576359b0f46933f68c |
|
BLAKE2b-256 | be5c6e98e59160007a47fc0db544f6bdf41939eef293f88f9445c1f39cfc5c8f |
Hashes for pyAgrum-0.12.1.0-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 734cb130fe0b4a8787bff1a34218a4551155ad9c87d3d506474cae64982dcd8e |
|
MD5 | b4200259fdc00b76825c7d00547276a8 |
|
BLAKE2b-256 | a312eb0feee01fd99aa84b7d351bae326dc39d1680307c87af810a9d361f9f5c |
Hashes for pyAgrum-0.12.1.0-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84e1f3e34eaf4b95ebeb5f47b4a17e6944ae7c3896da9c3f1e4d9d7145a8a816 |
|
MD5 | 86538749f5fd4fa12f6c4af798db7f42 |
|
BLAKE2b-256 | d2a263c922506823626a38dfea3f9ad3651f0a3ea926a8f3a368339e351bceb5 |
Hashes for pyAgrum-0.12.1.0-cp33-cp33m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb2bf331f8533200087c09bae7c39c607fdf3a8c9b20c28dc1a79f44d75f6e72 |
|
MD5 | d80a7d542dd9dfe930f571c0702402b8 |
|
BLAKE2b-256 | 835bd3e1c693fe76d2769767d1df05d1908e384e79a216f1d491e7846fecf314 |
Hashes for pyAgrum-0.12.1.0-cp33-cp33m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a619edee75c14c5b8c37ef1b4b492eab7e75bd02f5a2ead8870e639ebbfdd5bd |
|
MD5 | 35bea7cb98e24bea1249411127fde737 |
|
BLAKE2b-256 | 67b610db3cffe878f93e6fb6902bebc56ecaaee1e0014a543119d6cb1a1a7336 |
Hashes for pyAgrum-0.12.1.0-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94b426952f38dd47ce770afdb7f894dca5570a018d18328bb7c5770c5d85a71d |
|
MD5 | 606cfc3cf7209288f038c692811a98a1 |
|
BLAKE2b-256 | 57273385c0d76a92d7a57c386608dc896b312e13adb690a985f33bde6b900122 |
Hashes for pyAgrum-0.12.1.0-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f37b9109dbcefcc485a5690e5e07d5415a38e14f4c98ab600865e685e71f17d |
|
MD5 | f0cfe3a2466ec3ab1814b32b6833499d |
|
BLAKE2b-256 | 7dcf86e8d1752e1a18f327610a5cf4fe7f2a5f752dc0c3808cb284a07ce9e56c |
Hashes for pyAgrum-0.12.1.0-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60fbc187563aa3ae8052b4d796b2c9048036d36da157bfddda4718406d6628ae |
|
MD5 | 947b81f5bac02db2f582f74000e79a5d |
|
BLAKE2b-256 | 3171d84c3ca29e46c341151b4ab2ff313e0ebe9c4770de2110146daf5b275173 |
Hashes for pyAgrum-0.12.1.0-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae177ea11fb5b64341ffe416cafbdf5af72f64613efeb1950c460e9835529679 |
|
MD5 | 945b77601cf797891d343bc16963fbbd |
|
BLAKE2b-256 | 660f4237df3b6b77b141dcb69b9f07cb054c437a9b225d013b2cc9df54710328 |
Hashes for pyAgrum-0.12.1.0-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ef513b9750e6312c85df6d58d4ffd18aabaa3e596504b20dc8db6ba368cf5ae1 |
|
MD5 | 2fef02a7b5ec9845298dcbb08cb3badf |
|
BLAKE2b-256 | 95ba57e98cd3c55743e4506c0805858fbf362cd1af7dc8454079d0c6c7a1070b |
Hashes for pyAgrum-0.12.1.0-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68e2e0ebe75bcd59d0dd996f9af506df45472d1d1ccc8e81eee092d14ecd1b97 |
|
MD5 | 1f115345e015298d0638d8d2d8f15a35 |
|
BLAKE2b-256 | 1d28c73ddae7c0964fabab215dd0fd3995cddf0665824c194795e3618e5ca4ca |
Hashes for pyAgrum-0.12.1.0-cp27-cp27m-macosx_10_13_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85be4791a6f682f33497b5264b26c18e87899909bd03214dbe23c3a64b3949e6 |
|
MD5 | e84f74c956a2c15f8d5ff0801faf8fc2 |
|
BLAKE2b-256 | ba394419c269034b4475b8dbe0d4c366eacfd3295a62182f66331e2c2263bd9a |