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.15.1-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0282d6ceb0a488a993ad813670d24f1d5808350878b6bf28211cd87e776263a |
|
MD5 | ae0f46be5b4490f9cd9a4bc17d77eee7 |
|
BLAKE2b-256 | 28c21df9388f88151839155dbc3f9cbb793273abfcc3cff001c3a57118d1aac7 |
Hashes for pyAgrum-1.15.1-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f251c224ae1bbaec074e57c1123886f069d0d3ad50be80710c4b83fabb8d0bd |
|
MD5 | fe2add243ad5428a284e5962647aa794 |
|
BLAKE2b-256 | 3d37229bfd75497086efc9d2791435c165780a9fb1a4eed76de4e985ef38ca59 |
Hashes for pyAgrum-1.15.1-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d8cfd97671612949fb4f49b070c678c8e1e7272ecd51895a317b417535f8b16 |
|
MD5 | 73e00bd2b0650e9b5a3e22c1ba188166 |
|
BLAKE2b-256 | 4268b4e81529c5619af12cb8fa22985c498427032880a245a9c46f2f31aa601e |
Hashes for pyAgrum-1.15.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2555f37541965874375f492dc0452edb864be1412e12e37b31304c28af4533c |
|
MD5 | 646979aeb33f5e3243dc7163107d70d9 |
|
BLAKE2b-256 | 72adc5c114511b4e717fc60eab37bd35495d1b690084cdf4e8bfd5ab30ad684f |
Hashes for pyAgrum-1.15.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 900267eb0cd8fe545123d3a2fa85d6b7cc8896a722af3c26834a79ee3b955bb3 |
|
MD5 | 097322234c6fdf139c2a4be76b22cbcc |
|
BLAKE2b-256 | 3dd02d0dfae39d0f97d8772789f2c095e01068828b296832bb8c7d392eccc42c |
Hashes for pyAgrum-1.15.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7176ae4dd79225e87c06a9655fc78c8753808337a27c63343fb9afa2cc90d7e |
|
MD5 | 32863e064423ba9c569ea2b988dada7a |
|
BLAKE2b-256 | b30c1025cf6ca50b56057f3eb4641d702eac6b2e16a6b7eff6a3c5ebff7e1e24 |
Hashes for pyAgrum-1.15.1-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbc91b570e0b1c66c8ad95fc674dfb5af20edafb1549891d8ba1aa5e95facd5c |
|
MD5 | 7feae7d28c06d27b8ac767a96a9c811f |
|
BLAKE2b-256 | 58b2f5b0b6ddf50d78860ac2e1205912d3941601a0a8c723c1d5b89026d698ad |
Hashes for pyAgrum-1.15.1-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0c5fe8edcede874061181e0d3c7e2d484a7e9c7e5fe29c5b8eb847f9d956100 |
|
MD5 | eb8fe54ceaa9ae6262259dcddd06930e |
|
BLAKE2b-256 | ea8a5c3052a032d45d7c7d50fa62e46735efa24f7c98d358f0ecf90f9f565b5f |
Hashes for pyAgrum-1.15.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0444ac1f6b30230db89f12259ff541d8a72e900e4d207ef4672ecea14fa10e0 |
|
MD5 | 0fcfc86876bef25edfb4409f1c7f8d25 |
|
BLAKE2b-256 | 1e523441d0274e3626bab4e0e50d305c388f95f19ad6f93d5fb40ad83a34c1eb |
Hashes for pyAgrum-1.15.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe4b3942d5625b19e2ff285b56da074dd6deec84d0f0c4f86dd0ce56925fcaa3 |
|
MD5 | 62cbdc6ef0552802eb753d36e3280ace |
|
BLAKE2b-256 | 4603b72bb0e6d9d2666b75e161ca0a05655f34b2fb3b66cfda33a1f59ee3e702 |
Hashes for pyAgrum-1.15.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a6b838e5519824e51ec500623098c8b7f2222e94e87b92581421cc7197f46ed |
|
MD5 | e1de60d2cda8bcd2d2097fa8b2d0305b |
|
BLAKE2b-256 | 9ca8f3dcbde119f00c5806f04231c5b753ecf1389005f0d8c042f4df60cde21e |
Hashes for pyAgrum-1.15.1-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9615ee0fcb5f5a94f67eda3d3d2f8f33424c4f8f929f73c56f7dc056c89d6a07 |
|
MD5 | c62cd6a7d384ebca27675c13728c278d |
|
BLAKE2b-256 | c7ffba480290ae4cc4fd3f209431b4991f8fd6fe59063c4018d43ebbf2b14232 |
Hashes for pyAgrum-1.15.1-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a23dc48ddff7ba56575c4d4e812a896c80a20c910efe94882d24d078de5332c |
|
MD5 | c293da4228a26154f00a4b56bbfce903 |
|
BLAKE2b-256 | a2503815c45f9e85c72723bcaec41b7f826bbe80152ba9b0d74b1e86567d6194 |
Hashes for pyAgrum-1.15.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 968176a6f5b6831665ad867f5033664e1ae40db6664ad7ef8b15e1c9871ae44c |
|
MD5 | 5aadfa2137549e7f5b31645086307ce6 |
|
BLAKE2b-256 | d65bd716a8c2a36a6c770503cac014478ae493a24ecab7d8ecb3c058c3852127 |
Hashes for pyAgrum-1.15.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0ab124ae598d41cfbcbd52886c005e35e057272fd85b7b35544b6cbc7c1ff6b |
|
MD5 | d239d3634d4eb2d5b722bd14b68e0191 |
|
BLAKE2b-256 | 2bbef67da1a51364d1f94d0397d5c41631368cc35e3a0badde68c9cad0941f7d |
Hashes for pyAgrum-1.15.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 265ed596b63d33014b3ab083554b9710f462422af68a88e3ed2a37e55949e99f |
|
MD5 | ac65a55b96041197a29cd95a2fa2a244 |
|
BLAKE2b-256 | a6fe082cf61ebf73b2767597e621bc26f3ec415554714d8dfdca98c95f1e8b09 |
Hashes for pyAgrum-1.15.1-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75564ff5c4a1216fcd56b24605187996081b3b8c874427b23886b66a1caa81ce |
|
MD5 | ff7ea6a9b542ff3ca0594c7464bf8965 |
|
BLAKE2b-256 | b54d79a522cd24546bfb170324f2e2d5706a0f1beff2239067d0e4ffac375f3d |
Hashes for pyAgrum-1.15.1-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c521d909c33100a4efda1ae4f6cfe7b8d5b15f2a671d4c2c609ad779764b8920 |
|
MD5 | d178024939a7fe0cf2659cdc42f46cfc |
|
BLAKE2b-256 | 37e5a067d15b6c61a97bcbc6775af7e5a9b5381626a4afdc34788f05f4be10ba |
Hashes for pyAgrum-1.15.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 321a161a77184655eb813d556e7e98f69ee0e8a1ce2417a1a4c2191d0b275172 |
|
MD5 | ceffc7291c3a882684a4b281189f02ab |
|
BLAKE2b-256 | 51bb58275e76dfecc7a694d4c79589ebdfe9c2555eb8374f1a126f801939ffd8 |
Hashes for pyAgrum-1.15.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dda11add7368ec482952d15e884544a218696c076dabe06690318dfd50fdc65 |
|
MD5 | 6c0c966936d7fd17aa13542fdace10f4 |
|
BLAKE2b-256 | 58f8670e943b20ca11a180e1ed5021a782763a44920eb3523f0cc13a16648c0f |