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.dev202410111727562243-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9eb5bca17bfd22b42326a60b5620fcbb90ae9b084833c1683bad12ccb6bddf5e |
|
MD5 | a1cd45f54cf28f95fe8f399a5e9a9dea |
|
BLAKE2b-256 | 4f2a4c6e80a381a16bd09e3e2c2c21ad38224cbb51e7dcf176ba029cdda1d1f2 |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77307e00340cc3f2353047c9ba199953b64172f98c35a31943f51576037c709b |
|
MD5 | e32f2840f8631e2a4b1085a78272edde |
|
BLAKE2b-256 | 43df27c7d386112e7bedf98cf143fffd2cc97083ef5d098afad543e394a201bd |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afab18eef6686e7bebe7ee070236f4355e89a47b03f31692bdf321ec6e81bd35 |
|
MD5 | 8ddd26b7589f031944a9118ebfa70adf |
|
BLAKE2b-256 | 525e744912868e4788386442f4f6b10dd2741d2ad391f4d5219f010e733a0b7b |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a887aaaceb433385559ea7408edffeda9bcb7bac74be65f3281d5633f0f4858b |
|
MD5 | 8f7225060b4f3a2eede9d62f99385f60 |
|
BLAKE2b-256 | 26f65ce719c353326cae51f3f953cf27c20f8b2be7aeed9bb8c67b53429cd1dc |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3cbcae2b418de72024a3cdb59653c787b767d0f3c4b049644ff261e0aacaa84 |
|
MD5 | 76edbe71cb22adfb40fe9c9830be5923 |
|
BLAKE2b-256 | 438fed2600d0fd3925ef85dc1b999bde45f8aad34fc84da4560fdedab5285117 |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d15b936acd1b7c43dea0c0a0791695abd610c551be044e5209dc871165f23075 |
|
MD5 | 25c36d7fde50da2b77ff743e0d600ade |
|
BLAKE2b-256 | 5207d3d4555da59a4a6f60f4a69cccb124d8b4726b9825fcfd6334eae9d2f2c0 |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | babb80d510bf5db64da59312a4703e009fd8cc12ca53495265f281c555db0c7d |
|
MD5 | 2223e3d808f8cfc9a6755b59bb50a79b |
|
BLAKE2b-256 | 5e398530196172b07f9afb538599603a8c7ff0b923e2b01dbf16e7abb735ef8b |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1d8cb44c32dd0f21ad37fe2e0e0e1866dbe04317d0ab02640bf5be591cb4131 |
|
MD5 | 3ff1d11e9664ef51e147030b7a65b852 |
|
BLAKE2b-256 | 1bad0aec1bf852f9e4546840593a56d67374f085661222e429a5f5727115eb6c |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df20fa39bbb8fbb03857158e9c32dd1add52d79a46a870e34de3ea708f814df1 |
|
MD5 | 0d9b88a44d30a6a6e7db75118e56495d |
|
BLAKE2b-256 | b70a422fa348e4bf4af238e9d3ebddda69c54e7cd89972d17875badfa1d95352 |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | daa1ecb79a86cb7b7b095367761cc490e0e4817fab0a42abdc5f6ff48bfc933f |
|
MD5 | 026a5d3116a2fca552d3ab4e57f952b9 |
|
BLAKE2b-256 | 083c3cff336980d6943f4e7d4ce59ded1d942f204b7ac23db948db9b50d90617 |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cce8a442b7d30097beb34f67614d03f57ce38d24599f6909aacab067cb4efa5d |
|
MD5 | 72aed24a3fb5b712c767cf67bd95156f |
|
BLAKE2b-256 | a8811feea3b44b0f9d22b0dd3fc74c888d96e9a3ac803cc2f39f5c33ea7a2054 |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a478cc97bb3fd9befe1c4b788ae984bc185476b3471174117abcad3526dce706 |
|
MD5 | 3f65c6db12aac72c3be951e9887098ba |
|
BLAKE2b-256 | 1d473282b748f85addc8f65a4154172cbbe2657a5b70e6b2a9c45e6f7dba2970 |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9aa33afc2e23ffb36c23c680ff6f0eab7be87423c983f2236227c583634b7edb |
|
MD5 | 563f9ba365a0988432a25a615f7d8c87 |
|
BLAKE2b-256 | c08f80f6dee5fbb2218a949562b770977c4bd843f03d97993736f93a7603664d |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc7eec424c93fb2701e46d6de930c8ff8a86d64f8be81da81c63a5da9bfff307 |
|
MD5 | dc2d63900a553724b44bb38184f40190 |
|
BLAKE2b-256 | be49d6a00ac9f7500efbbddd05f7d7720a897ab3b96aa91de2d11ae0dee545e5 |
Hashes for pyAgrum_nightly-1.16.0.dev202410111727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 707743183211c2b88226aca9b3e30a419806139faefd585d77b4def4f9e278d3 |
|
MD5 | 94667f886c87121c90faceec14e742e1 |
|
BLAKE2b-256 | 543bc6f7c2e2e58f8ae10fb350d5e50947147b79f7bf2c421c641803fa12555d |