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.dev202409141723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a666cdc8a518339335c359165e261c28e7b730fccc44f803474cd98313e2a3fa |
|
MD5 | b0cdad6f08950652962206e7881e8d75 |
|
BLAKE2b-256 | d020399b7a8ba6365e5c3597c83093f239b384d5a9d28989723095d0108f0253 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 063c83e13581f5772e261fdc7ce1bcf62881cf60873f3f475171b1b8f4902340 |
|
MD5 | 2480da9b54b4bded1998f7c6689c2a4f |
|
BLAKE2b-256 | 759c5523bc90590270f7e0b3b8b9cd942caea27686724bfd5c954db1e4a9bb2d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35ff471e5d5f5781db103993b07f90786790397ccc60b12f61526f2bc3ff52af |
|
MD5 | c528e69179a3f8975efc15eee1d9c527 |
|
BLAKE2b-256 | 7f4426955db331100e41da80d504cb85c8308da618dfbff7898c48185be28409 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c49f5e86c4d7ee01bbb1a94a7d08447d6cc534092999a8807c9cb5cf31e69143 |
|
MD5 | e330ec423a26fbc9d1d0b372d360d25c |
|
BLAKE2b-256 | 4e6e60d92383b0c5f63cbb5f79ccb5c4a5ca9dc3fbb7398b7b3f0cf2b9fc4dca |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ab6751390023a32bc57c2eeae7aacdd663e597ceb7d5e26a0c0ed04208a90e0 |
|
MD5 | cfd1876e34a64b6f0b6495d8685d39f1 |
|
BLAKE2b-256 | 47753d45a9deaaf1bc4f665dacf0f798f52f72920c6c176a6d948ae6acd8d580 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a330c48ac2f73cc764f4f470eaffb8c52db5a3e146f3b17f8311304d5da4728e |
|
MD5 | 99037447b023c29f05577fe65367a800 |
|
BLAKE2b-256 | 13a1029bfcdb92be1ba1251e27110e55d41b5dea0eca464fcf1b3255d7537873 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a0267f25c39d70775eeb1db56a7e1735e76a04fdf0d38e9cf6077d1c5b75251 |
|
MD5 | a4b257412196455d2d8fdc87c77a73f7 |
|
BLAKE2b-256 | 15bcc58cf3585731e7c7b9134aff6e4fc954d7732a604ce1aa56c181a2a0a422 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 478883fcf965eb74ec6c2f1564a611f2c9d54bf4cfea23709c601782dd71eaed |
|
MD5 | 85b2db178f7de8309e6dfcdc37b519ea |
|
BLAKE2b-256 | 17a7876949cff3c9dd729671871c6b1999af63a02d9e13df7c1017d0e9bb78c6 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 372afd855ba9f52a24b00267040f5b80cbed963eb422580389b16bae681614e0 |
|
MD5 | c500e567657bc5b084d7eff3e5e50673 |
|
BLAKE2b-256 | 729ed722d551ac7504b1f420aa3fbd6ff38df94733e34ae94029fba907c4743c |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d0e2c75eeeacea76bbab36836f5c0afe679aae0e550758383440d525ec87b5b |
|
MD5 | 919a0db00da1e8782a46e367d8584023 |
|
BLAKE2b-256 | 97248e3d87b648c1c319213633305dfa8866ba492dd13b160b8776bc9c218b0c |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 965467d2f86e01331d723d2bdee1004a5952ce2b6af6cf6cac2b622e132a3a7c |
|
MD5 | 58a10255ffedad61d5e9ef830d6ef65c |
|
BLAKE2b-256 | 2a0afa13ce33a29a515eb83d1202f2f66d3d11ccebd035c7963e109de26c9ea2 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6d9db637ef1f29d96c5f9c9d1b14a522b2b645cc5d702f7aa11d973995d7a67 |
|
MD5 | f15c5ca945ea93a3f20c806b71f302ef |
|
BLAKE2b-256 | f2e34e35c94bdb1d11575c5b153042ea368df0ffddd1df59138747ee91a296b2 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a419c355775b714c856e9dc94c5d5ca46e11a02dcf7f3a53a3d8c765f03d23fb |
|
MD5 | 217992d0353840009bdc8ccd0fb5d9e3 |
|
BLAKE2b-256 | 6c3271602caa91341d889326cf8b8e4c8bb7ef0a586cd90db257c0e0a8e634dd |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05b55dd427b4a3f2a5fded00ad73c12f15f5395c5aa538ab3a556381fa476b83 |
|
MD5 | 5addeb54fc7868c8386d486634b03e88 |
|
BLAKE2b-256 | 47b1f68b6a8a97d8c949aa044c8659d61f361914de14fe258d260bc179152380 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fae75d1756c749f21f7c1d493ea5769baac174a3d36379327132a2242c2ab366 |
|
MD5 | 0ebe42f5de3c4997d4b897a3b4e2c2bb |
|
BLAKE2b-256 | 2b6872c2fd5c2895add455014a55e3a9a679d661c51429fcc63de9fa07d45e1f |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 196ba1ab0034f195d4b791ed876878601aacabb92f18f246ff66b43612ae3628 |
|
MD5 | 68fb08ce270bb8930db8cce7e2d4b02b |
|
BLAKE2b-256 | de653f5455c69e6383dc06bec33ce1d28dd0d9882095683e6515b84765d6a093 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc0ebad541c973a60c250069a8dabb760849a77f5d9492d024cfa90b3745079a |
|
MD5 | ac29500d07a81ea99e921c05eb2d9406 |
|
BLAKE2b-256 | bc5195935f6f6b555fd1ba29785efc330dccc897beb08b4bf9c531229bd03a65 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec8f7f0f29fecba49abeaa7b4cda2df74de7bbc8386d0bd24a6bb643cd66cfdc |
|
MD5 | d44624f8cd5bb719bd8c67e13979a5f9 |
|
BLAKE2b-256 | fd03f55bb1d460d6b8220cdf4f5dd3bdd53265c6a30c465419696a395360dd45 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed29a2caa91a7e9667cca3dc8177b043297ea1e1a30b5dc02cb003f8a2b3712c |
|
MD5 | 9d9219b5b4e936f6e094aefb12a502ee |
|
BLAKE2b-256 | e4cada4cc9d6b66b477794319e27eef4beaacf094ee18afe125f0124449fee6a |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409141723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6777f1ce0b9bea101a97c41d506a51f0bca2bb52c2829b36cad33c24428ad269 |
|
MD5 | cae0b97fafb1a85d37fb60fe34e66dd2 |
|
BLAKE2b-256 | 80237c1424991a7656ace02e87865bf5fbb2a0acb1c94a121c59b837fa5a8a35 |