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.1.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5cca2ea5c58d25784459c80d053e072a6c2292790714c77b198e6335540a0566 |
|
MD5 | 44a8bbcf3b037df64368f9761c045130 |
|
BLAKE2b-256 | 4b9e2c8434639936a0a00f36f4b16fdb299e6d0e377dc1a1252d7a19aa92e58f |
Hashes for pyAgrum-0.13.1.2-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bed3be990e130324d5a580180f683887d4499e242fa7fe262a82f1872eea58d1 |
|
MD5 | 647e3915bd6a39e630de4addcc87e5c8 |
|
BLAKE2b-256 | 16caffefe99cec8231f636046a2735a347038fbf1fd129b51a379e0f1d45c409 |
Hashes for pyAgrum-0.13.1.2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 279cafde50dddd78c80426501d7153fe29bd0ab9f9da385110e79f1d30e235de |
|
MD5 | 5d5772e742b29e37429d516340aa9366 |
|
BLAKE2b-256 | 3e1e7b3cbb2d8a26b55113655ed9c2d02d40aacdae780d5a75a4e41ab5050135 |
Hashes for pyAgrum-0.13.1.2-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4cb3673cc74ff92c1998c599dda10c95eab60b4bd81dece17afc810ba4e596f3 |
|
MD5 | 386e7e2df62b35ecd02ecefbabf6b1db |
|
BLAKE2b-256 | 072e4a24e2bda3ab464e120935fdddfe1cb2b10457d3e8ae9390c8061c8e2230 |
Hashes for pyAgrum-0.13.1.2-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f14c7ae45d249d54821256692532bd85fcc586dfa8cddc18518b0a472249af72 |
|
MD5 | 550f1f70271a60d6eb75172287d5927b |
|
BLAKE2b-256 | db20d1dd51851ab8911da65e765a5c48c826f017181e42d251430b8b4b85ba7b |
Hashes for pyAgrum-0.13.1.2-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b0501e8b14bc1407a29c57da76665ffdcb47b4743a0ffa1f5ceb06981f25700 |
|
MD5 | 7a18a192ebfa0a51db44cebf87075ef9 |
|
BLAKE2b-256 | 3903259981eb1404072eceb88d3e6aafe1fd82a91ad9ea917d54a18c6208ecd6 |
Hashes for pyAgrum-0.13.1.2-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27742a7c93470e5efcbec08d5a6a711d98716d80cf70e3375617742f50ec40b3 |
|
MD5 | 9448ad9e9f6b62e1bc5ddefdcea1c35a |
|
BLAKE2b-256 | fc322368a2c49407c122963bfd72e3edef5b38680cb50cd279f7e596649b671f |
Hashes for pyAgrum-0.13.1.2-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06f1ea9d32377f8efb807e4426e0aad06890e77e9d1d06d7e44ea4f6b5626a36 |
|
MD5 | a6456bab1682ae038a7e3b3603f7789a |
|
BLAKE2b-256 | 2744a2a0f33e1fb8dc9cb39537d3d8c492266259b67e257105f635ea1b72f74d |
Hashes for pyAgrum-0.13.1.2-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 005e8e60f3532d40880dc12c6a6381fb83c827cdbaf7ceb22595af680f5d3790 |
|
MD5 | 61b0bf9aec2ac2fd425419a1d929869a |
|
BLAKE2b-256 | 2e0df3fa01239dd4c121cf22827c88672f7bd7b902f5765f1a237e1c7cbf2665 |
Hashes for pyAgrum-0.13.1.2-cp33-cp33m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9383b9f8447eebcc55dc603580c2f07bdc0e269a4052895ecdf371ab9d110e91 |
|
MD5 | 6dc93ce49de636e89082194eb868fa53 |
|
BLAKE2b-256 | e46fb8f066095f68feb26bf749abc951f15c6e88e8190f87e280dd668ab220b8 |
Hashes for pyAgrum-0.13.1.2-cp33-cp33m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6da7a7ea1de83c68a6dcccaba3096dd825c22624a2a53137d054952e32cdedd0 |
|
MD5 | 4715741ab2f2fc8739b66ba5666751f6 |
|
BLAKE2b-256 | 216f1d8980c3a8fefb93743b2e0f04e4e8a5338b951f8a8c0775612507d30d4d |
Hashes for pyAgrum-0.13.1.2-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b334f844244065e180a8a1c5f3e8824879dd465c497eba4184cc225479d380d0 |
|
MD5 | 4fe27ab563eb83131bcde40a80ec5c3b |
|
BLAKE2b-256 | ab753bf07f2c2d12ca72c4a525194284d88dcf9619fbea563bbc1d7cc9a089ce |
Hashes for pyAgrum-0.13.1.2-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98e6ab2fdd98b5e78f2e73aa5ae058ee33d6e4d40a7b49412a949af1be19b9ba |
|
MD5 | de7b7fbd739c053938d9915618d17959 |
|
BLAKE2b-256 | 28bd7a22b172070b14a9db73a00e476745a89406da781598ab57b139232819b8 |
Hashes for pyAgrum-0.13.1.2-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fdd37145f75d3b89bd0634f91da6b5fd6d280a1ee9f8f1a1cdc6987aacf2f18 |
|
MD5 | 14d442db9c660637e96e66c6419eb100 |
|
BLAKE2b-256 | 0cdefa540d80e3bec456ff34b7937a0f403361ec63a8fa62afeab8f7e5e42900 |
Hashes for pyAgrum-0.13.1.2-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7fd532a102bdb10f5fa644f90bb9aade90532cc9b7acc8b4605bb786ff4ed0e |
|
MD5 | 3cb49d443d1d0f47c3059b01fc7a4bcf |
|
BLAKE2b-256 | e6e333fdc6e8895234136f15ae4acd070623a1dfa8c93291ef9f43dea4dd1491 |
Hashes for pyAgrum-0.13.1.2-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2f9ac74e4e1d6f95fdbc847617165c17ac51f686c2a0b04258926335e69c14b |
|
MD5 | 45efdcf478dccfc74465dc4830d39665 |
|
BLAKE2b-256 | a28f3128795a5404a3797fa8ec36e0e0e2b19af22722ff54fabdc4d2dbfa29d5 |
Hashes for pyAgrum-0.13.1.2-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6a66f2a99b65a6c3bca0acf085d9b3cb2a29028694f4aa1b0052393ee5e9127 |
|
MD5 | 5f95be2ec73cfa6776b75b7fa4327c2e |
|
BLAKE2b-256 | 30773cb8081a82b5ac7601d1b0681ed283407b83fd874dafdc7068eea54b619f |
Hashes for pyAgrum-0.13.1.2-cp27-cp27m-macosx_10_13_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78adb8d146de1df0eee65c0cf430314cfe5c54134f1a1e1ad96ab2c706a64570 |
|
MD5 | 0c046adedc44c8fe74891be317529cff |
|
BLAKE2b-256 | 83c2ad9b2c224b7249a7888280e69eee8e03fbdf07c6f9760102605dee9b0bfe |