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.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c18b1e345c87ded8b90327ac58d4780ca783b08a0fab58421162a9995b525b10 |
|
MD5 | c171ddd5494237b8a45b134af0dcf1e8 |
|
BLAKE2b-256 | 92a585742827036b63f7d4369e976ea6d2ac9954c25a7c2bfb9456e9abd1256d |
Hashes for pyAgrum-1.15.0-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 22b309dc60850f5088d56742fed8dbb14dc64f7603d0503229cd3104900c4d25 |
|
MD5 | 5cf44f1638814d01aa3f69c1a6c2d271 |
|
BLAKE2b-256 | 0f56e696e575af0e86e986308f04f70a1f6dd17227fa1a2b89bc84e3c045670b |
Hashes for pyAgrum-1.15.0-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e30bbc3e3df590dd2ea0765b6ccf499fa5d706e5d4ee86871ed4902e337e4882 |
|
MD5 | f77b69452d171381ac0e5be302424c8c |
|
BLAKE2b-256 | ad2e5271e053552a9454ae1e4ac9cca9283afbcfc42b1e730acc6eded96d8ad1 |
Hashes for pyAgrum-1.15.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 528bc421e74ed4a8144446de2545ac5da53e633661dd7a9dcc3989316d90c581 |
|
MD5 | 4a4c2afa880e7446d278b3fdf665928d |
|
BLAKE2b-256 | e289454760cb6f4915e031aee9330e4ad861962c7c435df62e0b801358c07cf1 |
Hashes for pyAgrum-1.15.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6d6e43816e9ab23998ccebdb9fb4a3525eecb8f5ae88d9553779cb239b884da |
|
MD5 | 6de091cce0815f0d0f2cbcdd6fd15c13 |
|
BLAKE2b-256 | a7aee2e76e2d8e7dee8d2e08a721a20506fc2fb9d7a551098f4d5a8916373d3a |
Hashes for pyAgrum-1.15.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe015d99ffb6566b19397c8d26473a6741dc53766976fc5aa593fd8e84e51c14 |
|
MD5 | fb65df909fee53b20ef6961a729d9e6f |
|
BLAKE2b-256 | b03007b0e3591b89d94abffb8581e8e5f609b21c7b06078655ccda64513f2546 |
Hashes for pyAgrum-1.15.0-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb5ca8e724514bfeb4049be1c24d4c65a47be6c858adca45e3aaa402c061eef7 |
|
MD5 | 00ab20b831d1a08f30c63ba013383192 |
|
BLAKE2b-256 | 9a177f520ce4190ce310229ee183299c928d4bc4da012fcf3ffa0c4ca010c87d |
Hashes for pyAgrum-1.15.0-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd28cbf0171a8c93aead78b4f1dd18e2223209abdeadc2cb53c9331f1bdf71cc |
|
MD5 | f0514a0fa48883071f8edcd0cc0688ef |
|
BLAKE2b-256 | 821b4f3c0bd1ed1177fca94694ac97a3c128096bc980ac2d81b105fcecefec8a |
Hashes for pyAgrum-1.15.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1aa4132df926788345a406720987bd9bebe085e1e4b0209b444759f30ceeb7a |
|
MD5 | 62b631d71d2a39fe3c6552bf362790e4 |
|
BLAKE2b-256 | 5bf7816e6be045d44dddd181db83def5b5094dfd378dbdc8ecdbce2c96ecaefb |
Hashes for pyAgrum-1.15.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee12f3509257107c3df0db9d1ae42da9d278b2970802ea5d83ab8aedd7ccd9f8 |
|
MD5 | ad47949806510c455ab6c734b582fe0a |
|
BLAKE2b-256 | 562cc929a3449389b8c78264a727fac0631307f02a5ba0fad7ffa90b031a707f |
Hashes for pyAgrum-1.15.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8de18e470c17dc99cfeb6b8866207dcf2c84c1f1b9adf4cb2e9018ba8e5be736 |
|
MD5 | de87fe5a265c06ec7e9bda50e553e5dc |
|
BLAKE2b-256 | 51c123666924b72eccda0a7a0da177cf0dabf656278f73ba20d436542bf3c4fc |
Hashes for pyAgrum-1.15.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2bd2530f53ef210cd54aafbba7d5b8e6789b4bd0a4298760a985815fe1086d2 |
|
MD5 | 4a7a58dad90f5a7da5362f398c180c2d |
|
BLAKE2b-256 | e722e09cb0003ce5bd109e3763c5b2b599dd022c3dd932faca5524b1f20a6276 |
Hashes for pyAgrum-1.15.0-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7cbcc4f2042e34fcbe83e618c0377eb2303979c6278238f1baf038e2bb9faab |
|
MD5 | ca90d2209c0a6421225ded3e469b87bc |
|
BLAKE2b-256 | f1a6ddd4aadb5d7001d623539b11a3b65f5826c289ed1a15bfd5db1f3597237b |
Hashes for pyAgrum-1.15.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58e78a7a92c82900a906177759ee3174e25309db1b3deba515e158bb64e53b1e |
|
MD5 | d7dd903d1c4db1717f4624f19c94cd28 |
|
BLAKE2b-256 | 66d61666b87c74c91040524cdf9c585a0984f94bf05226dd3fa3f74a2bac6072 |
Hashes for pyAgrum-1.15.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5af666f6cd353b31a5f3e15b1d2bc8ca3cf985ecce49645311c64f7f4ceafb5 |
|
MD5 | 4997532971ce31d21612880a68814ad9 |
|
BLAKE2b-256 | b9046cdabb111517a47df73afc739fe47d8da6011f8cfc76154b21c68bec936e |
Hashes for pyAgrum-1.15.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 140fed4e7b079a5d43d5ea4a9159144f5347a0e4e11204ab4d312acdaa646928 |
|
MD5 | bb504c15eeeb6a0ec15fe1f7feb12491 |
|
BLAKE2b-256 | 49d1efe20ac0952bbe503922511c8b7f142831bf4ac5b96686bff1c467f0edd3 |
Hashes for pyAgrum-1.15.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 511c38aa0ebd5071922c7d269dd8115c6aa4a26845dcc9cb3d9788b2bb1a3161 |
|
MD5 | 6f8363c734d27c640eb79a2d7bd2c650 |
|
BLAKE2b-256 | 0bf63db4ad45dc0443e0e540ccf1f08943e0c5f7832086bf4c7541ac753325ab |
Hashes for pyAgrum-1.15.0-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 020c68a439b30d31302c67948379deb1f0351f37876f08d9301a8b2368637a1e |
|
MD5 | 9052e08a4f81c3a1103b9856488ef739 |
|
BLAKE2b-256 | 2f381fb319e80e509e37540460357cc094a41ef1290cafbd0071888ab62d9401 |
Hashes for pyAgrum-1.15.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0da46e218c278793d43ae15e89a155ee5028ae5f20220947ece9f78892d73b2 |
|
MD5 | 81d9b8e0cb4e4757b2e092e01a755802 |
|
BLAKE2b-256 | ec1aea83943b90a01d1bae8f225eb9547984fceee563468e1b795b77cda8d8e8 |
Hashes for pyAgrum-1.15.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee1c3e6d6de4ba85fa09d23610b6da1b1058a6778d6dc5cece3552df0bfab130 |
|
MD5 | 0c8b539560fc8dbf9513abc08bd13942 |
|
BLAKE2b-256 | cf46c6c82df32bf8cd028be2a4f85d370d577640cf457ffcacb675f8fbcda6a5 |