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.15.0.9.dev202408011721169663-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 028ca431798cacd8cb03b126df7476475ded9181843822308bf5be0066fc9d6e |
|
MD5 | c13f27138afec3318410f83ffa560d0e |
|
BLAKE2b-256 | c8acaedf26f3d3cf035391f190116c4177f71a208d038af41f2b3597946044b2 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d2432e6136edd8546718248d4df7e0a97347e02d70e36567a3fd625e8d11d0d8 |
|
MD5 | 22f8c99fac6992e5922703e58ba8407d |
|
BLAKE2b-256 | 466e826618451e79dc3ef71981743661471567155d8fa24ac24bc4c8a60685c4 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c11feb758052bbe04613536932cc2848355d5f78cb374866c1eb9d5233c09afe |
|
MD5 | 1a0114d7d174424eb4db3a1f7103e883 |
|
BLAKE2b-256 | f07cc833009060c3e79d153000dc97ca3f296b953b79d29c6941d83d276ee830 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98c7c9d5075e2bf146ea837bf91a9b10315abd79c36fbc1a99c6b602c54545ee |
|
MD5 | 9ec243a33760a2527729913259b4f27c |
|
BLAKE2b-256 | 6f603481ac7179f641e9bc4e761c536b2f220242d600300e9fe999825826ee38 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0f4c981ed77599bbe80e3f52640e48f9ecdb2ffba2595f237bea3d8f1400f70 |
|
MD5 | 6398f51c20243faef167f30ebe1a47ca |
|
BLAKE2b-256 | 1984c3552c16ec8a7df9143be563acf8d739acaee5063da25866eee9ce2bfc3a |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a912f9917a91534e9fb4badfd3e70c9845562cc952d5ab16cbcf8b9129431d59 |
|
MD5 | 17bbcd7faa0ecf0e05e5785fba7c59a0 |
|
BLAKE2b-256 | 7d37e71fd7f3473f3edcd7543fc23ee913fc136a3ce421ce3f58a3d422e41b05 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bd3080f240965f62e1d5f1e8df78f51364eeb6cf015fbbff82a2e6625478497 |
|
MD5 | 423f455006681c61f3a7f812735786c3 |
|
BLAKE2b-256 | b651955cdaa5a44ab112670307ca59b93ba3732d6dd836965ac0ee9d19b045f5 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 656f0ae0ff0d5cb3025e7053efb5c66ec399d773e5c3a0d60cfd61214efa287c |
|
MD5 | 4013fdbac3b71c9fbfc098c4ce0233db |
|
BLAKE2b-256 | a5f4823a43cb4e7292c615ac7bf78bb2330ac52bfa51e0d20f768fdd394b802b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93dfc186a911d7e05182f7ba6185cb9d005a9885ba2ea6045613b91529d7d71a |
|
MD5 | 1b7f263cb5c02286c1ef17bdcc2b361f |
|
BLAKE2b-256 | cfe968b37ef3058f3f6ea80ef106d25ff3048d069a957857b742f13074941d73 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc535c936d1eabe31f530b87c4942972030cd535d59b466eca0e18d4f14480fe |
|
MD5 | 7b1588ae568ead6bd2b9a1e79245c289 |
|
BLAKE2b-256 | bb1989e74d15fa31506a430596a702956f86867d95cfd7eb193505a5ee349236 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08750d8599e3f315a7639206fa219ca17a841a6d044e142dd7ff7c23b2b35233 |
|
MD5 | baf04a28caf813cd31cce069e28682f6 |
|
BLAKE2b-256 | 9b2b78711222d756d86e3a8977ae8de98912c32552c324e312146401081af66e |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98b45b50a61a13f379c0572c5c43f11cbafcfc34ae0ea9334f465536239a6b59 |
|
MD5 | e68f32aa561396ae6c4f6d0b6d040bfe |
|
BLAKE2b-256 | 409201b2bfc0f1840463b8dc3668fa65f4b1e649aded4a8823ca7738169e038b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bae3cef43f578a6b04ab47a9d43939f76f9425e2abdd10bc553cbcb64cf31c88 |
|
MD5 | 9be29a68549eeae1cf92dca217a56c85 |
|
BLAKE2b-256 | 78c256ced500740a70adf7a4166fe03b43205274131cb8f1b195b5c1290c4c08 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b7a5c3e225ccf7954857f8504d2c4a0ed662cc65d7f142630a4c4c58a641963 |
|
MD5 | ae1468b91234a973cb2a773322e38bc1 |
|
BLAKE2b-256 | f1444e7a4cd454526eefb35200848333cf53fbf15a746a0ff94273f54af7e6f9 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd24974d14ebbf673f10fd7594ea67554e66d02e4b74d97d1ae18dc74888e86c |
|
MD5 | 90426f79af115cc91381e41301059a45 |
|
BLAKE2b-256 | c75b239d9fb0854702430f48481bc460f959f239028447841ef854ec24d8c033 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52842aa7a0dd8db795b611309cf21f1f48aebd30c0f561b43c46483378d77847 |
|
MD5 | 5b9a2dd5709955ccbbf04b5d2ea2eef0 |
|
BLAKE2b-256 | c1584aff8a70aa563da424e89588b290de37f9e35119be9bc268163ec7b2c8e5 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f6a13da7a7a0b6dce5b18afd1b054c99317616597bffe497a7340ea979dd6a3 |
|
MD5 | e2385347abd56d7d974ec0f7f33e4ecb |
|
BLAKE2b-256 | 47795357558bb05f3ef0e19b97e6000b6079209b9137fcf5bede36ebda7b4375 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fbd5d2500e4684011b181eff83993079153f1e329faa0f87440cad6b7aa4bfa4 |
|
MD5 | 65c63626cf645237f8ef39bedf744a49 |
|
BLAKE2b-256 | 3c2c79c84d15f7921a907bce7b1d58dbd3bb5682358b86a8cc759864ae0a81b6 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 230ff1572c84f0ffdfa96688181104f27e31afd4a751a9c7471e13764c2d2e09 |
|
MD5 | de1aa17062c24a2aa0ec4a505172a32a |
|
BLAKE2b-256 | 005b87e8f4b88e3393fa1cf9da18a5a7b22848d01e93c21a85b092a45a1071d2 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408011721169663-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e727624e76024f29accf8a09f0f2f959c409c616b1acaac0a7b9b74fb51f8908 |
|
MD5 | b2b5d6979aed6c790d460a95710ea745 |
|
BLAKE2b-256 | 804ac09fe46052cc38bcf6c40fb7e59f96384b125cd686293edb4b1369ae1528 |