Bayesian networks and other Probabilistic Graphical Models.
Project description
pyAgrum
pyAgrum is a scientific C++ and Python library dedicated to Bayesian Networks and other Probabilistic Graphical Models. It provides a high-level interface to the part of aGrUM allowing to create, model, learn, use, calculate with and embed Bayesian Networks and other graphical models. Some specific (python and C++) codes are added in order to simplify and extend the aGrUM API.
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 ?',["Yes","No"]))
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)
# or, equivalenlty, creating the BN with 4 variables, and the arcs in one line
bn=gum.fastBN("w<-r<-c{Yes|No}->s->w")
# 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")[{"c":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")[{"r":1,"s":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 hard evidence
ie.setEvidence({"s": 1, "c": 0})
ie.makeInference()
print(ie.posterior("w"))
# Adding soft and hard evidence
ie.setEvidence({"s": [0.5, 1], "c": 0})
ie.makeInference()
print(ie.posterior("w"))
LICENSE
Copyright (C) 2005-2024 by Pierre-Henri WUILLEMIN et Christophe GONZALES {prenom.nom}_at_lip6.fr
The aGrUM/pyAgrum library and all its derivatives are distributed under the LGPL3 license, see https://www.gnu.org/licenses/lgpl-3.0.en.html.
Maintainers
Lionel Torti
Gaspard Ducamp
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_nightly-1.16.0.dev202410091727562243-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c28cdfcbfb4ec4ae5c104c96b2a6799b0ecc58fb5b40b90055d6d1dd8f285486 |
|
MD5 | 2ab4f0237802fcbd732a9612ae554295 |
|
BLAKE2b-256 | 22301d229f1f5ab8ea0c16b553f7496995cc85e27ecb00181bd35948885fadf9 |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a7babef9de3edc4b992f3f94d6199ff03d6558d30f158bb5845524b6a1e842b1 |
|
MD5 | 2b76ada4880e20000545168cf7fd5f3f |
|
BLAKE2b-256 | 988dbd61c53ebbceb515672104c8df1865d01ff9ba50c2d0dd28d07e2807524c |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32e25a558ee3428aea3d5494950a4d7c87bcff5ad51f83c70df9cf9c2c8b10d6 |
|
MD5 | 3216009583f3ee83036804536de87275 |
|
BLAKE2b-256 | 3ccc7e7668a0eb01670fced55aea0c2d139de5dd9c647f0a402c1a201752fdf2 |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8601d7d9e5ec5ad695b51c9741a303488f5b6697d4d9a8273cf30fdaef754e84 |
|
MD5 | 8076a00b19f081f931fe0f6c3d0a8e4c |
|
BLAKE2b-256 | a1dc432f0575b191bde62627eab89f9165e03f62ec2f0aa805d5e2450047aeba |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a778ed404ccefbad8577c65d762b52894846cfae5f34c4ae7b73880711c3903f |
|
MD5 | e77d4a8ebf2162c3bc2dc11987e882ad |
|
BLAKE2b-256 | bed4105b5caf248321dbfb8596820c9d7f278127a32725d6abd924eb10d1eb90 |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55282a71963327544329e5cc6cb321448430feb8f8ba8cf4db98d20dbfd725ea |
|
MD5 | 93e2639086349ed0ee745e0cd901d074 |
|
BLAKE2b-256 | c96fc17824c4d3e7260b25d2828a5ccff844545df07dd82966972d8bf45cbf3b |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 827752c7742246299002b492f67452519c6356fc9da01a521f4cb57617a099f3 |
|
MD5 | 7c9df1d206f71d3a7005db47bf99bd57 |
|
BLAKE2b-256 | 92033d98d840ac16799a972155416b67837e0d90de69b53618956288991a4ed4 |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e38dea977b24d9bc9c86edb1d8b9ecaa1ec00f2a3db92fb5cbb5ae45e318357e |
|
MD5 | df6cda401a8d9a21d38cdd8e07785167 |
|
BLAKE2b-256 | f6578cb2824615e03ca56b69910a686744a064ac775766e24d39fc106342802e |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b16c3daa7136beabbe1eaffbc47b710b4bd2a712cecd0e07c6d30633ba733663 |
|
MD5 | ea26078c30be1f0f5fdd71c2d320c6ba |
|
BLAKE2b-256 | e13fb8aacaa9e69e81ec99dcd127661419037dcf62277f568b86f9ea660ea72e |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f14064c76772afcddff5ab206726e0a1bb6d3ba113ec0a1ad7468f04dc6f24b |
|
MD5 | 407a8640cb666e4a6a3c134dbc31f4ed |
|
BLAKE2b-256 | 3a077e8765cc00457fc0b9d8c26a126c7849a3e83a4752bc03c3d85a45da779c |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05aaa9509fb0d07c54b7680b6f5b21cf9cb754b90c19c5f998f98434b611a301 |
|
MD5 | cdf2a477964881d6496c4ebb17fddf7e |
|
BLAKE2b-256 | c81b9aae2ca892b1d5b8356f9dc9f854617b4f02e3771e8cdbf54cee2ea62169 |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3ec0fed7d2fce81e7cad8533541f0e140e54f8f2aba669e44904c8bce8bfbd9 |
|
MD5 | 56a92ad897e932b2af791621d2f27d41 |
|
BLAKE2b-256 | 6447cba2325a233090f49820343d10df7f0339dd2e5a1af6b0ddf678362eeb2e |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eae91f80e041a53c53c0e0694c287aae29aa58458233783c625caabc9dca9042 |
|
MD5 | 8443ec6163871cef73b65beed636ed74 |
|
BLAKE2b-256 | 13465a21eb953c98e37bc27085c90cfcd4084e1815a79305f103eabda9d0de27 |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e67d0c2307689ee402a15063bda9d3d9f937a552854f936c6eb28ca04057d35 |
|
MD5 | 8ea8a0c745bbbc7f861ebf7e4e08935e |
|
BLAKE2b-256 | 6a179bdc384e85d52f05b47141a01041ba91f05a53f29e40a4171aa2e5c94279 |
Hashes for pyAgrum_nightly-1.16.0.dev202410091727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f30de7ccb91a66d0f032b18eb95fa08c74a5c9d4d7519176756b787e8a054088 |
|
MD5 | 425f30ecfc51baaa9c34eacf14404607 |
|
BLAKE2b-256 | 25e6c7522ed077706aabbfa1bc9a5c29f4394d77a825507945fd07bc78fdaef3 |