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.17.0.dev202410301729615378-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 141536cec048cbdab971b772260708f2511ed3c99868e978e61c2a9c00fb293e |
|
MD5 | 413b30598ba35a465ec3c8e86c0cce59 |
|
BLAKE2b-256 | 4d45e22d4a2a181a2ba014601ad6067dbc3d03c59562cbe1b803ecf34b6d4e63 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp313-cp313-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f09443c1b42f8bace2cb777b5978afcf8a1c2f6f55f370f9d43d938410abaea |
|
MD5 | 73a23c7f0503880f68cb1c9c338e7dc2 |
|
BLAKE2b-256 | 552a3ce97aa3abc02d7332b29fce44aa82eaf5aea97f8099d8a997e0edcf260a |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp313-cp313-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aceebfa15bc62b76ccbd27da00d4d0bee580acc67e28d196321cfd9871c85b4b |
|
MD5 | 04cf6a817746edaa04974515f56d2249 |
|
BLAKE2b-256 | 01ed899c61d21c33038e87daafc80ca648df719ecf6c6d39293a2be7e0ccec62 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 502b5b96ebd6f17af327f4795641356c527fa96f8b00b5d73120195d99f447c3 |
|
MD5 | 7ac5ff2a56311119486c8ece6e461abb |
|
BLAKE2b-256 | 0fe7496ebc78da92525318032cd961139c7c05c33faf00ca93883921254ac681 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5b5eb610b55114884ff8e7e76d8b07406c5512f2910624de6f2fedc5b76e0a7 |
|
MD5 | f72f0ec4afe24a6ebdc45c54789bb55a |
|
BLAKE2b-256 | 91733b7f4c5aeb82c490a3f0c82f0ce5016a603e22cd2d683d37f9e224067d1f |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f41eb3c9a5d83cdd164d0ab4d8050a2ddaaecfb2e716e580e2acc883ead0add |
|
MD5 | e33807194f56db3d09f23291a62bbf6a |
|
BLAKE2b-256 | 517055470d9b35d0e3a7079d15d340e78bacc9aebb1243d170ed8d4171a788c6 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e81dae96e299d572cffb0555c40cb6a4c13e0753662b4132d512f25987c772f |
|
MD5 | 5228219d3a7a6df6a3d82d423eb666db |
|
BLAKE2b-256 | 7c8df534f18eae23e399135332db38f0c75fbcd34f03ce1e8229df5de8742e83 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1711f11f51a388678392528194277fe23359ce9fb7c2ba5fc1de16cebd367708 |
|
MD5 | ffd1bada7c5105d3c11af54c0db18a95 |
|
BLAKE2b-256 | 7cde6612d28f10eda7335fd8a071ff9bcb186e670445b0fec14b70813ad7c513 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 893762225812976e4aebd8b9789648fba65f4a6833cdbb7d0bb82aa553d176a5 |
|
MD5 | 96047fe4f27b8a793abb839da787d1bc |
|
BLAKE2b-256 | a460d9ab7a37dcdf2658eb42d331120204098d7fd0dc9a1592a29d0c223f45e5 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6933114b5f289179486b9f63d92583bd7578d1b2782a02f8c0e399871d70f3b |
|
MD5 | 1c59b9063864042ab665903cb02d950a |
|
BLAKE2b-256 | ff3d7e1e96bd0114f18b7b1d49a55712112c908f8edee1333ce0046455b8b631 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ce4c3a1729bb29fbcb55b5a40e9c8d42bf168b1ee6cd6761658ab5842450a49 |
|
MD5 | ba2305161ce2f2afac273497f17642b3 |
|
BLAKE2b-256 | 18a4b72d3754274e72011d47fdacfb6292437dab22da8ac494c43fee500df66e |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27b17e7a9cb9716c8b37e556cafc3384e53846261e67c6c71b90c36c0a566e7b |
|
MD5 | 323767cef0c79afa5170717159caca65 |
|
BLAKE2b-256 | 92d6c4ddf2998e0315bba06ae79b19393d88afc9e8d333bccd4e433077abb674 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a215dbd65090aefdb565c4af4a16a632cbb3b97143add139bcca5b5296f820e |
|
MD5 | f37609a905cfe24c3c479a9e2117b7c1 |
|
BLAKE2b-256 | 3f3db26c54434cb0c78fa76d1d328b7c6ba1bdd9879042b7cbbd732f575b90e3 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 546c43c4019cdd5497e945ae5e89d1a7491b322e4576da4b7b88f4ea8dbe2cb9 |
|
MD5 | f3489cb6e948204b6819b0dcda0e88fd |
|
BLAKE2b-256 | 5d14cfb92603975a4028b4f53ee6563883876d4c973cb78ed16d70041b816adc |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05942055a704b6d175864fa733cfbd08fe66205efea0b0a5a720c7971ecd131f |
|
MD5 | 0623d2dba5416b457eea5ff5f5b87c81 |
|
BLAKE2b-256 | 3855b25d90e4bf26c0223f3214256867a076d2d6b0a3ccd17b8a853c8d770b05 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f8c8cd850c4176c47be20003629c21f807b4aec6bfef9a96c37d56e65a5c3d3 |
|
MD5 | 86220c730767ca83d06b66a7f6dafe39 |
|
BLAKE2b-256 | bc40b6a05a125c2693440fa5b00a0fa15ea2784b3e93c705912b372072bf8278 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be396e150c17b7ef26d030e4013fd951aa11ae0fd909b79a55a4baee2ca72820 |
|
MD5 | e2344af6f5dcb0acbc9e53987502d5ac |
|
BLAKE2b-256 | 828ae180af44e633d27676a2eb4cf1f6d0747409eac5a9e4b76e7f321425c74f |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79c02d8b87c56ea4c881fbf1b678aeacd4406333c971b56fbaea2cba000bb577 |
|
MD5 | 6dfd70a60a9643a47d3ec65dfa7bd3ab |
|
BLAKE2b-256 | 52eb2b26fb05d3949cc8372c9ad35ff47b93aa32e6f70d25945a03254f1353a9 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ce908762e5b49f9e5291ddef1e76b722cbe59323729a459985635c92c6e94fe4 |
|
MD5 | 1bef639abdd0bc23dd7cee690fa4fb90 |
|
BLAKE2b-256 | 3ac359c9a43ec7b383791531ac62c527093f4be271aeca89473643f7f29fafe5 |
Hashes for pyAgrum_nightly-1.17.0.dev202410301729615378-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3838f7d8589ab487faa9beb1415e6cd27b4dd27d9c8f4a703ade8dcc795465b |
|
MD5 | e0297c7f61fe0194955717f8039e4aa4 |
|
BLAKE2b-256 | 8d907e46c545797be68f39dae380acb6a032483a506350c73f3c1a77147fb05a |