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-1.14.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38ce811d3223489e2ba45eeb6449749ed65d2f895f8f7da86752a052405f9c4f |
|
MD5 | 493d2991d28712e4f545c743ca3e572d |
|
BLAKE2b-256 | 0ca4acbb5cf335661dc323314c977b0ad91174a8f75183f6a0a134fd687a477e |
Hashes for pyAgrum-1.14.1-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e56f4d55d0b18539326a36602cd0fd1de625d04b02ce37e4960b873a57090041 |
|
MD5 | 349f8c97226ddc219ce7ca9cc39a3ff7 |
|
BLAKE2b-256 | e47d4c42ee91974ea631b195b8e294245af69d42c7fc3fe54c2562e9de2db037 |
Hashes for pyAgrum-1.14.1-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dcb19d70b3bd840e8fb231832b8e0112a985351ddd3283ab991b15adbcf682dc |
|
MD5 | de5db75e87de45535c547aa636a0d8b3 |
|
BLAKE2b-256 | e07cfba297fcce50afaa75f58cfb4a676eac40f89675a1cd2fc15d9b446f468f |
Hashes for pyAgrum-1.14.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | edb164971464265caaa99bbaf85b28a8fcfc3a7e03d0be440bd6775ce0462cd7 |
|
MD5 | 9fa2cb85889669f1793ae2034f7ec10c |
|
BLAKE2b-256 | eaa919cef86e0b585200a23f7ba181ad95bc648928d4539dd2e1dac08a811b77 |
Hashes for pyAgrum-1.14.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c58654b60d0242c9bbc0241096f84767b55d8a8d6f3acd6d07cc84e10a0d9376 |
|
MD5 | e2d246942a4785dc268dc04a098f321b |
|
BLAKE2b-256 | 9ecff802416466b75deecbf7f31c3b6890ec84725e5465c6f11c2b5710972bd3 |
Hashes for pyAgrum-1.14.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cba47a41bf8aa740b476c73dabf8bd81b1d7617505030970ec17938ece5b0731 |
|
MD5 | d2ca676e67249f0c3b966457003aabe8 |
|
BLAKE2b-256 | 2a40633617d3088daaebb0bd7baaf062e0cff5997bf664a0f25cd4a24c4c5c89 |
Hashes for pyAgrum-1.14.1-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5471eb5a2be88427fda5c3b808182b11dcf69116ffcdaa428691d9d60303808 |
|
MD5 | c51361ad50365e9d324ee4104d661039 |
|
BLAKE2b-256 | 3a6ea6204b9762631cdcd7c0837a1ef5272617ec16b0666db92c05331cd7e823 |
Hashes for pyAgrum-1.14.1-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52dc4f7c8b8688f9417f5459c81d863c76199e6b609be814bce3d872dbf0a42f |
|
MD5 | 06c9de096a3fa822965df72b34414ef8 |
|
BLAKE2b-256 | 6f176100c943a83c27610a045710a943e49365f05d2b4d66ba83552347aee4f5 |
Hashes for pyAgrum-1.14.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 368b29dfb811968a11c275af026b6466c075a93729b956dd4fa14b5f281a9e3c |
|
MD5 | 5ab73761aee33a073c01525d8bdd5e43 |
|
BLAKE2b-256 | 4c7f71a818df7d7a4d383de25ac4ebb0197aa9059fa1e2976c18f4cdd9bac8e1 |
Hashes for pyAgrum-1.14.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bc346441d36efebbdf36bbc20726dced36bd7ef262644d57c2d8dc2689cf037a |
|
MD5 | 202c032a8b5cb35056e7028bd1a0de75 |
|
BLAKE2b-256 | 40019436bfe646ce09c1f06e0b677e7c3de3ccf9804fc704935010706b6f570d |
Hashes for pyAgrum-1.14.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 500650a6ec873b856fad3e34aae2f297adb9e57dd26cf3bfc876e41d7ed91e35 |
|
MD5 | 9737e630ec8f05f74ea2e4a5836340f3 |
|
BLAKE2b-256 | da03e6801c6c2338ffa7205bddac6db21e0ebe8d223733948f22efcc701b4f2c |
Hashes for pyAgrum-1.14.1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f499aa161818e638d6f4061607d702b5e28752e3ec55ff34fc5bf14e7680491 |
|
MD5 | 6431fdbd4e9287c5a8ee39682cc079e1 |
|
BLAKE2b-256 | fa662c9372712c5643c5d2f96e2882bc666e34f3d6e88bef9e85bc810d7a30ed |
Hashes for pyAgrum-1.14.1-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbef143754e8dfea6a188241ccef375e7b576fb3b03631bcab0d8e5cd2d4572c |
|
MD5 | c0def15b838f734df57859796edbd53b |
|
BLAKE2b-256 | ee83f521ccccd39a4afa952d1d008050c9a178bb16df6689b0ebe147e21ce233 |
Hashes for pyAgrum-1.14.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6c7908813f807561ca5ae00d13e40dffa57965058189946a28466174f631793 |
|
MD5 | 4ba180e8603752c6042f1ca5c7d74cde |
|
BLAKE2b-256 | d584c6d3700c542866579e87a27385ea4e68f4f8d401dc40651ee625edfef816 |
Hashes for pyAgrum-1.14.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0190119c0ada4eb9422a2c695119a8ba5be39776f6424806ff11ad82101ff80b |
|
MD5 | b2f97749b7215fbf8af8ad3345345df8 |
|
BLAKE2b-256 | 8048d59da6fa7e8801d38c9dc85c2bb75e30ff8d32bf128f9639de4a78a2e0fd |
Hashes for pyAgrum-1.14.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adf85eae39aadf40591d4d1bc23ed17a2c2d512a9d02c3b60cb5945810dd8507 |
|
MD5 | f1a66c3718dd9afe2fd847c3c060bb5f |
|
BLAKE2b-256 | bac08da6ed27ba3ed058ca8cb0ef2ae255f53f431e9a70f13ae249b4f5522016 |
Hashes for pyAgrum-1.14.1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c93b78d566c0a005f191d9cbbbc64cc431d71e9c5f63ccb568af977c443ea2a |
|
MD5 | 2c079f7dbcab68f3968053564face0e7 |
|
BLAKE2b-256 | 0ebc54cb9fa25be95487f3510ffa36157f331b70c2492893fabefc61926953a0 |
Hashes for pyAgrum-1.14.1-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d497d8298d21afa31dd23329c1dd4b11e75a74112be1cbcd660fa7f9ee486d7 |
|
MD5 | bb5cb81a1a995c956a264013c4dd4158 |
|
BLAKE2b-256 | 9b09e20734b77ef5ff3256501e2d0937c0d5c1b03225fbec52e19598f50f7d3e |
Hashes for pyAgrum-1.14.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bb3c3875a7c43927ef844256f6d82ff6752ef7b1689448413257a88a89f3706 |
|
MD5 | 39f7b38290beb1849c63b7f38f35afc5 |
|
BLAKE2b-256 | 583b950422a9dc3314ff4bc8f4e6dda011ae0011f1b93aea4d6e6139200a0b9c |
Hashes for pyAgrum-1.14.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44a620cd4fb82cad6f1f26db1d716342dc3bbf2115886b900f36f40ad779d397 |
|
MD5 | a9009d2190d2694dabdf8e863161a60e |
|
BLAKE2b-256 | ed649776c3381a0c77e6928e77125b1c876db22008ede89187a8703c215e9b73 |