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.dev202410251729615378-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1a3e86630723ffb3d467423f50cd1657baeee782b0fc0c2d8197bd57bf8eb4e |
|
MD5 | 632f5931d0df1021eae7cfb099e3a432 |
|
BLAKE2b-256 | 3aebd5bfc900eb8114021173201549bfabf82d310afe1313a46c0e03fdbddb32 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp313-cp313-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55df459850587fc965662d79b4f7f728f961eb506d7aed5f2c04cadec6bc27cc |
|
MD5 | 19b0c69d24b7031c7b1480865fb644d2 |
|
BLAKE2b-256 | c8d1569f54ebc18ef55dc43fd69332a9967a8223ef99d3982376e19d61f2f6e9 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp313-cp313-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c088bc6e895dca294437e936b2e9ad61c4b5a955b674f1cb783b6481cc0b5f5 |
|
MD5 | 28587e1de5212edb3702a5d7db39b2fd |
|
BLAKE2b-256 | 06bfc6e975d726c43fb9e527a909a60d62c95e9bc9aa998ce319621d92995678 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 84dadffa913fe8a0c7a6561aad9251ff4429c6a232b59bcb52cc1f494ce4994e |
|
MD5 | 5d839c07ab7ee7844431fb8cb7280484 |
|
BLAKE2b-256 | e38a6bfa0eb78fe792e4a4d615b2cb0eb5e81861e10bef28fd2e2e71e2ea6a11 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7417e8148efb2b95e9929e67db007e360968d1470a83a21e91eddd31d477dc53 |
|
MD5 | 3a6a8de246c45f29fc2e45ef0624f42e |
|
BLAKE2b-256 | 734f255aa4bb53dca824786a526e4f8059b54dfcfa60bbad304dfae8d70a2abf |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb4a56e8b347ffdfb88a4fdd2ee7336fffb3b7f0065c15893c5a5b5478ae7b98 |
|
MD5 | 033505999d124f7e89920b7f32a920f7 |
|
BLAKE2b-256 | 6bb934ff702dd77e3068ffd903f62ecb6d045f47ab0bed6f5638c0ffe098e10c |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a47b7b906393b481170983a5bc3fbdf5e77033bc6450447800c8ae2995fe4d21 |
|
MD5 | d3683e0d5137d647dbf54a708d512c89 |
|
BLAKE2b-256 | 816e9ffc769889d3536488114f462ea7819a54bff7ba12652f03382554d30ec5 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a751adf1ffbf267a3dcf7fe7354e41790dd0489e1938c846f6815f5ba16c9c04 |
|
MD5 | 7247f916a2aa89b357e69e57e30e1082 |
|
BLAKE2b-256 | 4cb52250371f7b1be7de021093693c129dd2d434991e12faf6cdd1b529ddc9fe |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fbf08927d1d07e082d735d1cffd67f945196a73f80cc4360909e6447152466f |
|
MD5 | 93d826cf22ea6c3c4a0ba042cd9b174c |
|
BLAKE2b-256 | 6fd4c7288bcb8a07d12eef0e5213f2d6853d9f55b78847fdf91f44d0458eb540 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8747e6e48fe0cc89e0f45f6ef007fbc4b1a5f40aabc44284d0fb7e08f9fff3f4 |
|
MD5 | 31c007211785aae07973a024bf92c42d |
|
BLAKE2b-256 | 124bac7d8f7d429996d0e1d0f734de0cb22eb0a3095150d24b2b1e8a173a5f75 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45cd7ae2f12f16c4be4f7f5011982db44b1bb3cacaceb5cd9c640e57589797d8 |
|
MD5 | 54d03d9fe2532547c47fa27b26c6b5fd |
|
BLAKE2b-256 | 3f8298dcfd2521fb24c184be968747185589bc13b505ba7c8c82d4281f074016 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c54d8e40c055d092b53248ce646eee11fc044b8b0e37a53d643643e10b58419c |
|
MD5 | bc62b34952bf2e57537788c367903d11 |
|
BLAKE2b-256 | 50f9dcff0b7bc08512934ee12950a074e8788e97437056874589ba2caf6254d1 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0094cdc850dd156316827926d5d585b774cd3d0bb75e61262c6c2ef064fb6661 |
|
MD5 | 0d5c9f4589349a5f3f25756435dc2b52 |
|
BLAKE2b-256 | 49ea5b7d92cf444fd55a7aaf1dd8904336425b446fd130a4d87898511f18db53 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 348ab7b2726cddef0c7bc0da97caffbe1df3348aa817f88aef1ba6343bdecf43 |
|
MD5 | beff2351bde14c7dd4b94b6f7bd1e925 |
|
BLAKE2b-256 | 97c0acfe5595bc11c6a011f650167eac5b3af9762a68db83f2f04601025efb7c |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1209a17d48ae04233e8e8eb65144a889a1bafadd7105819fafe28873baf7594 |
|
MD5 | 93d6c3379496a7f3bfe7f3b63a4cd58b |
|
BLAKE2b-256 | 27f2c986896515d5958e2e0779e87adf852351b9a26dbb77b4ff7b9f2d1e3f00 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45be72ed665d4de994fba8b4cc0ebdcb2c5af34e7ede577ce3e67656cbcb400a |
|
MD5 | 05b3eb5615de94efabac1fda0ef83fe4 |
|
BLAKE2b-256 | 31d4ffef87e12a050a6f2f9b50f1b67e7f6463b4331cfcc8c81ccd6fac4d71d4 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e73bd3d6b235972f79a3f529bfb76776ba2a2154e454133f7dfad7188bdc3565 |
|
MD5 | e81d38da384d77bd94bbb70f73236e71 |
|
BLAKE2b-256 | 20bce6a9b1a935d86bfb73a66c68fbf866f1fca664ca20077927ffad023f083d |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a13753256cb5125c322034248a72065f3986eaf7afa46045acf00edc1e66600e |
|
MD5 | 9a1f9beb37fd71acefce7678a18ab2b1 |
|
BLAKE2b-256 | 470fb635dbc0012d1ae2d030db03fba1c0821686a8f9df89d2f4424310e26744 |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 918f292917644ab140287537d0de3bbd33c321d62e8cb5503e7a7971544f51c2 |
|
MD5 | 8d008859fea8a3b2b0cac00cd23eb098 |
|
BLAKE2b-256 | 006745fd12923370e2ab6222db5cfea7fe56b9f70f29f48b6e9e749ce7b357ac |
Hashes for pyAgrum_nightly-1.17.0.dev202410251729615378-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18de3a2f1ff48ff761448f803a51cb180f896d670bc065186ecc65450169bf9f |
|
MD5 | dd0d20c59ebacdfadbd29a02483342ac |
|
BLAKE2b-256 | 292950a84aa88afca413b665467918108076c406b3984dacad20b066375c56a7 |