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,2023 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-1.13.2-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec2385de3d2f2cf2921d540c92d9762a8ba177925eb7ff016af10a2290bffa38 |
|
MD5 | e8e88c49355b7237b0be47e99d1e211a |
|
BLAKE2b-256 | 5415d294f063d5429f3c389f2bbb4a5e0343a9949fdd47456ca8590dcf7d7efd |
Hashes for pyAgrum-1.13.2-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1546bad08f9b9586d7aa22ea32caff66f3e8e31a657342536930d1e7124108b2 |
|
MD5 | c7a8dd9b0caf653b9f1a20c38b097b58 |
|
BLAKE2b-256 | 426a1065138137204b22ded2c77516bcc2acccf6700fe491ee96715677051a93 |
Hashes for pyAgrum-1.13.2-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4cf60a34e1ea7c7314e284336464efa5138ba661e1c9c79e384a8a4bfe0c3ac |
|
MD5 | 433c11086a3af6b8998eef4e466c4c47 |
|
BLAKE2b-256 | 1881d01f3611de63c87db95e8a5e848c344a22e70fad639adf0e3a0ef531f395 |
Hashes for pyAgrum-1.13.2-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46a41b79e3343489e03d7dc34869605d80390c7790d80a9809a1ce324cba2c0a |
|
MD5 | d00e9046400eaf78c567ac1eaf511411 |
|
BLAKE2b-256 | c6148a545615083d40a11574681b3216b7e7eb76387d79a6246b9ba0c8961d83 |
Hashes for pyAgrum-1.13.2-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6e7f8dbd4251dcfb98ad26439f452433909920055201ba2fd500c2bd448fc8c |
|
MD5 | 261e175846e3252ce2e5d5ea2af6621c |
|
BLAKE2b-256 | 26192cda0ce124c00b2c3546b31283c94c73ba978dcfc70756fe369abc3826b0 |
Hashes for pyAgrum-1.13.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ab988ddcb51f18ac2361791c57500ff26d7d529e40711737a7dc73046cf97eb |
|
MD5 | 30290f90a9c188b1fbc43e9366cd7933 |
|
BLAKE2b-256 | 9021d1a3132ba5a3505de55971cd40eff02401cbb26a73010945dcfaac93e250 |
Hashes for pyAgrum-1.13.2-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7d7558052252e8c2f7ace626fc55003d04546891a7479b1002dc2ea947cd9086 |
|
MD5 | 656863f7e661940772ba1d6f6e7fbe4c |
|
BLAKE2b-256 | ee43f9556f963284f9921cc0d651250b0e67e877e3ce60db47d7b37489258d27 |
Hashes for pyAgrum-1.13.2-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad70a416a6ae0d38b04ce8b8636980095a1774e6d9c338af49b91e56fe9d87b6 |
|
MD5 | eaacb5a3ea7dca4c83db869a2131d0ea |
|
BLAKE2b-256 | 79fca25b614bcad290e56e6abb888b9d5943bc3546b2a0d3c554e6947bd417e3 |
Hashes for pyAgrum-1.13.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b8673f93a4ebb7116281fa3b7a025bc3aa17d61c61534b83a45d329463172f0 |
|
MD5 | d6260f1a733e3b67bac75a7717d15783 |
|
BLAKE2b-256 | f7bac801314ad691889958c2c18919617328c7d096b9e765240d4997bc909e57 |
Hashes for pyAgrum-1.13.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40c1c857b93a12ac618fa740d64970dcbc4935c55400fa54314b0ce3ec04ab4e |
|
MD5 | c479330d4125b1201f93113b84816631 |
|
BLAKE2b-256 | ef571c2ba923f28c22c6d8d35d4a29420087c7bb929a1308520928ad95b889b7 |
Hashes for pyAgrum-1.13.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29d4220bc1365d054b7e7323a3328eb4fa32e4a00f85a6ba18006a314acb9f92 |
|
MD5 | f7ff10001440a40131d59709af5d8366 |
|
BLAKE2b-256 | 620e9f8296e3442b3688ae0e94318aa7cc1297c892b5176f608312926c64d55e |
Hashes for pyAgrum-1.13.2-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ca2e208c3dd212daf2299dc38fa6245a869a29e1972222ddbbe5d29cc8947ae |
|
MD5 | 52a6ca7eea132558f1e062e9a95022ac |
|
BLAKE2b-256 | 8cda3d2347eab0941b13522189bf7df7a92e4a95b7b970cb733bb013de15a28e |
Hashes for pyAgrum-1.13.2-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26072f4a50b06d02756f5198eaed404d584729adfbe96951fa97d21425c0c17e |
|
MD5 | a4270fd2e5c9027e6b7faece88b74f1f |
|
BLAKE2b-256 | 7086392c42c9d20ce85746d62b7c1fb9179f82e5947e2bd943761e23f436e51b |
Hashes for pyAgrum-1.13.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a248927a94e9ad487a283ab907f99e37b3907ea2e080b992a04ed20dde1d9825 |
|
MD5 | 9c863dfe6178115f5086bd6bdb7a6e96 |
|
BLAKE2b-256 | ce2ac5150619295144486357ca5dff3bc4766e0d75c24d1914291ec030aedfb7 |
Hashes for pyAgrum-1.13.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 412d4af8cdddb57d827e3d20ca078900a739ca558f5cf87c9bbae05640970b3a |
|
MD5 | 59598a5806473395de9f551cef755ef0 |
|
BLAKE2b-256 | ee61b3bc16f5d7163be932954b8e9840ded86b0e22c8944ef14e11edcab100a2 |
Hashes for pyAgrum-1.13.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 543588087b4ca4b4548520b5765c941b67062e48a8502736ecabaf5f097c4504 |
|
MD5 | 07739dc36a1811dbdb0ac0e33155a349 |
|
BLAKE2b-256 | b926db906070fc9cff42f0569202008be95f6427465b1a80706f97d68fc2075f |
Hashes for pyAgrum-1.13.2-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e4982ccc883b0145111865578491cbf0b30daad2d41dae1a1cc1ddeed7e9614 |
|
MD5 | 086fae31fd5edd026ea8d698c877112c |
|
BLAKE2b-256 | a36ca23a1ef2887e00689611a99fb665383186a3cd96436c49f912fbb1ed3b0e |
Hashes for pyAgrum-1.13.2-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2e71376597b2571c74c0ea307e2f058672e2df48dc301dfaeaf5692a1cfecae |
|
MD5 | 35041e55f1229dd27f90a0270ab2fc90 |
|
BLAKE2b-256 | 7e352dbae25daa58b193f347e6866b8df202db81a206f428c966a55376d426a6 |
Hashes for pyAgrum-1.13.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 396a3c19320c951c7c362b1c1dfa3e34d3ea8bb30312c6673f43f580d264713e |
|
MD5 | d5f668582e13816e4f3469c2b1114ffb |
|
BLAKE2b-256 | 0170ca8bb3d64f1c84a25832bee4a2f53c219928fab3cf28daa0a6c992f288cc |
Hashes for pyAgrum-1.13.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 709cf55b112f26932ff5f84ca99ffdf4ba1294e1b5f46c4cdb57540cb440c153 |
|
MD5 | b4ec680679e7bc4164f7a243abb7037a |
|
BLAKE2b-256 | 2a2f9a30bb57bfc7dce008d42bf1ee7f5f8864840c5f5cfaf015e5b10970c047 |
Hashes for pyAgrum-1.13.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4366cc1d6f1bf1ae99a2454256548d646008c6f8f01c3dee50aec6641d31b583 |
|
MD5 | 684f32ef9f5ff731feefd0e70c8f854b |
|
BLAKE2b-256 | 6874dd4ec4884df60df37952e4f6bf7525705cda5571692d51a8c4bc04f392b7 |
Hashes for pyAgrum-1.13.2-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c25640268621d06d6db46942256782be1d29421297425e9689cb3f8bb5324dd |
|
MD5 | e21f90ce56c413daa690df826e1ae0fa |
|
BLAKE2b-256 | ae407373e49a9fd756fb71680ecad71855439c7524a9ccd9d670e88eb9effeb1 |
Hashes for pyAgrum-1.13.2-cp38-cp38-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40e10f429bd55b174a32db388725d6540bf05daefe5412e35c34db1875774a7c |
|
MD5 | 8def4961d1ffc6272019a8e1fc8aa43f |
|
BLAKE2b-256 | d0a31eb74feeaeb343850aa0c26cc3c2f79409c458d6dccd427a0e5e3b5caea3 |
Hashes for pyAgrum-1.13.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 386fbe264fc8063b17e0d77ca5ba97c852c4ca1a95a8ef2101b9c2a0c13ea37a |
|
MD5 | 0077c83c9eaf67563e1cf7a08d22c4f8 |
|
BLAKE2b-256 | bf9cefb368c9d55d6c7da5eaa0175aa19edc0ef41e92f150a7bf4f88799e5adb |
Hashes for pyAgrum-1.13.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc8147ca9e568e9484fe8cd81930a79b652e753ef11f94e1ced9b78de5fb9ae1 |
|
MD5 | 927bd0c9dca59eaa5ce7c34fc823012f |
|
BLAKE2b-256 | 0b0d9719e3a351e3cba4221f8577a49f051e25c119088bca4ce11e748eededc2 |