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.dev202410291729615378-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e919b3484d66e96613754932aff700f86d3c92f58138915379056e4462dcfe65 |
|
MD5 | 07e64ede626ed38e7a0234400232a7ce |
|
BLAKE2b-256 | 86c793df669c80694edb2d41c4efb96f8e6f3b5a5f2a786bb293d29277d21a19 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp313-cp313-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0911bdcfbc2718d6a6ce1ab0229d0ff60761a5b4af3697474b60051b6c40398 |
|
MD5 | c3b643da7c46ab18dfa98aa6ebec16ec |
|
BLAKE2b-256 | 22477b38f0fac19df8d56aa6a97ae16053294b9d7824013751fa0db866af5417 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp313-cp313-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83e0cb0dd604e551e8ced3e0ac9e4efb2ab7a9603df87985435899c79a067c7e |
|
MD5 | 667f42f2ae7961f8f3fd144389b35d9b |
|
BLAKE2b-256 | 94fff75fb0c2b6c1d896c84c5121ce4b3cd12c778482f96bf26bf5991c81e861 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9079cdd5182672dd781b3ac6b5fb9c5a248e158b61aafdddae8e8b50214b930b |
|
MD5 | 7b77e3388828aea33354698262108cea |
|
BLAKE2b-256 | 34f0ebe24a5dc30d6e7d0339f97638aad3347d330ff107ecfabc204453c3e644 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89444ede81f74914385f0fd735a723d93cd00e6230318718068cb0309e4ef442 |
|
MD5 | 1f1d000fde7ad69275af3681ef719cf5 |
|
BLAKE2b-256 | c5ab3cd7fd1dc0ac11fd2ce108a14ddfa40f521cd296d633fdac7cd02b9ca242 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4ff4c748baf4a9725303e5dd40d73cab83d346cebcf6644d4b9ef8783999442 |
|
MD5 | 2a557699bb4cc7255d3df676751b3a07 |
|
BLAKE2b-256 | 5d3f72215ad9683fc6a50213fa8330ed8f3b839f05d5b12e8466f0db3495ea2d |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 69eeb8ff4b8ceafe1ae34982df31c41dea57ebf2c0dbb014ee3c70fed9413926 |
|
MD5 | 4336c861e895ec0160bbd7561606b4ee |
|
BLAKE2b-256 | 220f6a1cec717417c29c821a65aabeae243717136e22457e826f61e06c3e2a2d |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f52637171d52f61a27650e902ca90d24ddbcd9e9999996e61baf51111716dfa7 |
|
MD5 | ccde29d0f33a86d5dc4e9217045d8bdb |
|
BLAKE2b-256 | 83c99e7767201faddc6376001d38f6c3bdbb92c827bef6bc55b1665fc9bd9d29 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9397cafb7e43b06f56d292272865a453f8a03b71f6671a29a69216bff3e4c3eb |
|
MD5 | 4932aa94e59c274d5bdc79b75a6b2cbd |
|
BLAKE2b-256 | cf8097e83c2b9e59fc0b30a80963175bb7faec7bc6f58af4a5f597d011217f00 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90815fb1cec9eb346bdd7541fc03849eab2fda0bd8a25126a0fca75a4466646a |
|
MD5 | 27734da2420414ab5c9187d1d03dee3d |
|
BLAKE2b-256 | a3997ee7cda99ee27400de6fa9eeef8f5780baf5e82e8b59a56e483a408e75e7 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2db403235f37f5bba8d4b94faa59318936a704dedafff694138f54741a15767b |
|
MD5 | da62a8c82da17838bb2ed9bed29d3dd9 |
|
BLAKE2b-256 | 4071ce10837cd210b91ce4224ff1490a0c24979c46abb2ed2ac58b40cff4e0b3 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbf2789e5458029317e17e41c8af1f4831cbca712c3ed01fe85a2b43d7640936 |
|
MD5 | ec7e1b5f28ff982f0f7e543dfd77adc9 |
|
BLAKE2b-256 | 592aae85ac3ca4dd6467fa6566585e349b9e7e03e3f6c111feb0be676aa1f6c1 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccb8cb3bc9389873c0a0bc635e226b465100c1f47338cff655ba7b2a0e7261a2 |
|
MD5 | ba5bbc0efc5ff66f864cfe1fd95d1510 |
|
BLAKE2b-256 | 68d837596b3abf735437efe9ff793cbd7050cda41123c402ca9fb8ba0d14f0f7 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7bb875b558d0f893af9006527b607daaf2e016563f0f6684f21ef22c69b80be |
|
MD5 | 8afaeba75de55e07038ddb6a9f7fae83 |
|
BLAKE2b-256 | 66366014ea73c2e80632947df2b3b4d553dd6c15d8d7dc9736ff5b8022eb0f60 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aea369244af17874a9d7c1630bfd2472c7a441b3ec902a780c10166bdffd4075 |
|
MD5 | 868b255b02c1dc5a78df21878913dab2 |
|
BLAKE2b-256 | 869126f4e5aec9da78e4123d48fdda7e2b3a902b6a218ce4ff5be7d18b17b791 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b47f6c96e7e5b53e0453073b893ef1ccbec7dfdb41a5f8c260974c269a204c34 |
|
MD5 | 852266c0e48368f5abba45b1c1ec1e9e |
|
BLAKE2b-256 | 5e4f400633795803488e6618593c9dbb1dda273eb759f9f23e7c580c4338b020 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e3af4591f63082411a066b7e4a383d883561b9a0e6364f1173579dc3b2c1e34 |
|
MD5 | ddb56e737ecc8387ba21fbdedda6c0a7 |
|
BLAKE2b-256 | 723222ce32e515c1fd9b76cc25c143b50271ead95c117f72120f1c8430c9e998 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7777da730342f2f9d0a5fbbf5d6be4fa1e400c9c4816f1e8957b310a1899c322 |
|
MD5 | c3a23d60a5596443fe07f1f3187284a5 |
|
BLAKE2b-256 | bc99620e51ea93e9b62b5c9b8df3922dfc4bcdcf1b865d0f5304b631ecdbb0c8 |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95ef3fdbe6a90f84c35d489f7b04098e8d6eaa34a0679f9cbd7b75c24a7edb29 |
|
MD5 | 926b33726522b1048b597dc4a376ddf0 |
|
BLAKE2b-256 | 1e22b5a26fdb24910bc0c8e5f1f474e76ea975909c5d3bc2e9f82fed717b046a |
Hashes for pyAgrum_nightly-1.17.0.dev202410291729615378-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02527b238b70e7e0ccddeb3bc7865bb83418e650d21ebd3e0f54840d07accd91 |
|
MD5 | c9a97ab227afc3f328bd0c9de76c821b |
|
BLAKE2b-256 | e7a5d9ca197cf84832a577afca0537a9699ae4d997641b9288a6498038aa3c52 |