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.1.9.dev202408251723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ae02c9b4004f4091d30c724df1ac6a2b56801ad0d3b3efd71c22640d8d43ac8 |
|
MD5 | 801a1780202939cc36263ded663df7f6 |
|
BLAKE2b-256 | 9942e7d5a28f3cf614a3aa622858231cdb881050bf958285101bcb4213539bb9 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 595d2ff55b7aaa13994b831273dd26f5891d1843c83018fa30a8bbfbe5f2d0e2 |
|
MD5 | 5a34f9a0ba174957d94086adc1fbb629 |
|
BLAKE2b-256 | 1d15886afad7b676a9aa8ef4b385cec6fa2b39f35d2806cb59d42a7bf7601e27 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5ed142903b4f738b7de46350e0d050da6caec1984f1b50091aee6f86a3e89ad |
|
MD5 | 0a58443164841b3f61edc32d16d2113d |
|
BLAKE2b-256 | 5254b273e235f216c2ce31642f724b5ddf659394f64d1f52c838ec21dde9e151 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe3bc2d3dd0a65ec55fa047e85f0339107a84d5d52f3e1ee8d08cbe4b6b28b3c |
|
MD5 | a059f8cd0bc990df620ef1253a10625a |
|
BLAKE2b-256 | f6c3a320b6df760b1f8456c10210633b834709fcf99962fa67b4dad6006cd155 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c682a87b266281bccbaa390747b39117e173a124a47e85360181dff1aa6b7387 |
|
MD5 | 78df0a04e10669f577ba860380dce13a |
|
BLAKE2b-256 | 16ad3e176e4bd4bdf67d022fc16a2047d92ff0f92939efb25eeaf4ac2ced62b6 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 543301b6b9ad8237e7b240c82424f0fb39665102931081c98d8443ac29b3b699 |
|
MD5 | 8ca67a7667781171ee60b0a3caba5426 |
|
BLAKE2b-256 | 8b36d95435c699f8f62b329a4b7b56bcacc3fd77f9bc67e654612227efbcbe17 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07cef7cdf7bef4b3b8414c12be4b576b1dfda063014dfe043bbfae5be070d301 |
|
MD5 | 97d34da5ba747b513e79796324b171cf |
|
BLAKE2b-256 | f1f4eb5ad5962e466bd47e99678298105162f67ade8d015ba3fe5816ea097677 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e41e8cfd3510666bad9b096760bf48d0448e10fd1fc899cfe4766fa4a49c56c6 |
|
MD5 | 83f96e0f5e387ceff43d2b3d026d07bd |
|
BLAKE2b-256 | 8e34edd7309f8d6704d69a980c1b69325477ef20df22bf7ec30d4ae7b841a01e |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c119fe3b06eb15438ccca3b149858794c524eb0b024d7332ce91ad617907bd8a |
|
MD5 | 99b275ca44d47364af217766f8847457 |
|
BLAKE2b-256 | ff65f13f481c73423c6911c40d7ac085ac28547ac397daa0d656e4969c4556e8 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a1cf91fb01ec4d8137b0d8836b6ced9950dfe729429cf63f6708fb3936c7dd1 |
|
MD5 | 244e3a0fa41e99261c9f3a8aeb92a616 |
|
BLAKE2b-256 | c6b20674e25e15b756430d236160931982c144c5bef20b58be5db33e7ac67df1 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97ccc4efc415113920c1d6607a891588b163a567d0394fd03248f0d81ae25be3 |
|
MD5 | 935436dcdaf65557a655942e6f07be8e |
|
BLAKE2b-256 | 7fe5595ebc19befcf3bf4d39e4fbff0f8900ae646bd22e6cb5fd700d0b9d9727 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c35bf93e2292e542927e579b0fc048354d2d5584bb2cf9a26f691936b3a7a0ba |
|
MD5 | 2ccb5e98571da3c1b10e9bd6723728a9 |
|
BLAKE2b-256 | 2e90f7c2dba4152710909a71bb52478da46c9d6c719e4b11cbcc784050259d34 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec558b98c412ae294b337a27c4c8948960f12f1ec7646d04a37b5efca5fbc8db |
|
MD5 | 8a555ec721e8768707df3b64db09ce06 |
|
BLAKE2b-256 | 3ced00616f2e8939fcf977e7d5d89a5460cdac6a0bd850b0441f77fee94a6c6d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9a23061bf2dab2311f0f40e3d32633bdb43e61bdd1a3806a13ded0079cee39e |
|
MD5 | 1baa63a80238dad2caa20f5d2af05f57 |
|
BLAKE2b-256 | 1a62cb816c9c2a9473c68ca33f79b6df9ac7e49aeb12e289915251f5777f85e7 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6408fabedeb362089d5ae4b81963c89a56e9bc2b8f90927e88ca323c7a707ca5 |
|
MD5 | c19a79cc1e529520387cecb583731f8b |
|
BLAKE2b-256 | 24301f002fdcf2afcf2037aaa0cc3e317ba45b5871a1bfd8496d85757f9e1a0e |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bc4e6486fa125fb7df647a43a48f80c85c4be26e6f98fe471d3b90fdab31d95 |
|
MD5 | af9529f76beecd29ed0913b871c66b81 |
|
BLAKE2b-256 | f00c152f28bbac42755d8b141b05cbc572216ca782fcce127f9d35eb16bdf2b1 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c0af6c0714bfe130034e34a5c2cce0ecb9dc31649be8716c5000ab032d390c0 |
|
MD5 | 0ccbb9ef0092cc082bae82c6a77052e0 |
|
BLAKE2b-256 | 12528fa3cfab4c34eb20f121733e49f8269d9a232465d62b1c217b724ae8edd0 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ece9ed919cb519354947e624941164bd25b3605896ff096db1835c0da1e3e7e0 |
|
MD5 | 05907b3d04f5d8b16a45d57810cb1136 |
|
BLAKE2b-256 | 255cc6d3a309cca17420eee535ca7bb232713a910bf9e7afbc1fefaa9dab4b47 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b365137de7fb4079744b57913cb34ffceb48822e623c5a5ac30b5f619588c1e2 |
|
MD5 | 94231131c5c73a190f1c6329536939ab |
|
BLAKE2b-256 | 6412263679aab7d88ee28f659b97043ecad35cd3cbb85aa2a07ec3df34e77824 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408251723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82e936d21beea9dde8dda4188476a7a254a9466508f10015c8eb5e48ad40a439 |
|
MD5 | e5532d60d86185e62984618dc5591225 |
|
BLAKE2b-256 | 1fd6717bcc44da77ed86a4be47050fbea888a5d7d1686b36c6d338a23b0023ce |