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.dev202410221729248609-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d80aee25421e79887f10ac5cbfc88df2c96bc278301e7e1c566574313e7f1c5c |
|
MD5 | 53fe1452395d1d35a6f382067399366c |
|
BLAKE2b-256 | ded3e95948ac71cfcdd33e9f93dbb098912ccb0e91212d52d9618c0516a11b27 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp313-cp313-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba71ea9a9a85e8a420fc6962d465c1bc19ae74468d5408a904425a3f7ea3d40f |
|
MD5 | c5b8098a1193f67150726ad40038e507 |
|
BLAKE2b-256 | 3efab2d1ba8c84722d394469729576f707a8a22f420cad82178383a59b6261f8 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp313-cp313-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 144374ef9fd50d44e1103c8efb6b29f2581e72a5669a14586cab04ffe1d55e3a |
|
MD5 | 559bfc590467cec6dd74ac6489980de0 |
|
BLAKE2b-256 | 5a4479863287eb2212653ef43522d63d43dfe167509779fbdc3b546eb1776070 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29f44ff9f1adf8ad8b4d953fba71c86fb30ef3dd97da995a929a49f060723218 |
|
MD5 | 1e60a62f341c12da2c9d4c5acf192838 |
|
BLAKE2b-256 | 8df1eebd286b18a63d16cb6decbcb197fbef22c4481244aa4676dc2a326e8248 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2be1a04e9c196d0781cfdbf9cdad0bfc8ae5dc07149e108ae63ccaf751d3d4d |
|
MD5 | 3acd25f7300ea1e58addd5610dad773c |
|
BLAKE2b-256 | b5ffccc27bbd58d99633e87a931acd05eef05195a2f399a939cbb96bb2dcf902 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17aa78fc1b9c67ea083226f37743a214dc4c15dc2c03ab6c5b4274e243d47c5a |
|
MD5 | 0ef0751f05dbf25acee653c9722c5984 |
|
BLAKE2b-256 | ed6680ab2dfcefd85168d88e70622fb874224a9f70201a63084de4ab0fb3a846 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1b12720e63ae8b8b6202c209651881fd5768cc35b127598b444d490d3a3c605d |
|
MD5 | e83b6496688e36a93d6f4436d68e5b98 |
|
BLAKE2b-256 | 1fe9662d6b2514dd5a637db601a4e9c374b0e26824e8b471a0b5925acc580aa6 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8336c55e902030943a6541a7062d4eb31d83dc386dd95c900aa5c6a93e54758a |
|
MD5 | 7f962f9f30b90deafc21987c2e3c4bb7 |
|
BLAKE2b-256 | 78c8cacbc09f637b7936180db4323433948e884e0d03e156e9c071052beacba8 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fe5ffb02e3a0a1a7bad2880be9ff30f0855ce6741ad3fb72fb3b61060e7bd35 |
|
MD5 | b8b4e2c8b13431065c333a521b9b53a4 |
|
BLAKE2b-256 | ff1ad69a39485019a80b20651e51ba7781b61702248432f6fe3e1355a2669873 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25dc7a8fd210d7ac0cac8bf1432206edb1f3fa8561ffa6c8974b6082209f63cc |
|
MD5 | 199cf8580269d386b793eefbf42cbd82 |
|
BLAKE2b-256 | 1bef9e7e7e4d56e39f7e68ae92e08a5ca3004698072fdfd3c1d8e32e7a8716e6 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e52bd9467c91fc261e442d1a621f3d1d12b0cec591517d4c1cfd99b5e592e321 |
|
MD5 | b620676e52eb1ba5a728baf7a4481f27 |
|
BLAKE2b-256 | da895da3c1ab7993b8f03cf6d983fbdde5051cd4b625aa2870559bccd327afee |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f926ab37ae0679c2bb87e65d02f8590e00123c394c536c6dc64ef2cdbb5bc040 |
|
MD5 | 37379035fba9845bbbbd37b5e00981a6 |
|
BLAKE2b-256 | ab8a220ea782717070cc023f91392d4359e85a12a9a59800efe14b52421942b6 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9ed9cd7688d9b84148f9776cb98e97c86ff84be1309854773d9a3066ff419c8 |
|
MD5 | e666f598a8f7cad235a06e9d99740ad7 |
|
BLAKE2b-256 | 9736c4d88cae5596f1007f73039f56589a3f8695e39cbb943c57ced0f232040a |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 839577120f904424d430d8bf3337bc843c7b16b15ef136677a1a408d37adc6d8 |
|
MD5 | 80f089bbc9552d2a5affe24019cf4f28 |
|
BLAKE2b-256 | 2ca234a4d72dee9d87e7f75770f658e44ee2e93f5a5e611acac553a4f1a2e9b8 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd1e6b1e5ddf45fbb749902b36a38eae41fdef3f26f58b70f93bc17fcea55b24 |
|
MD5 | 587d19913ebd1e8f2c6e33cd666957ae |
|
BLAKE2b-256 | 963d95fd05129163bce44221c1a4deb4533d2a17528a61e593d02bf46066910f |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 396d4dbd1d88acd9618dc45039a6f45a5e6c8e50c659d043e774871556941dcc |
|
MD5 | 71e03e96c71690a2694df758dd4a993b |
|
BLAKE2b-256 | 6711f7402c66b441d2fe4980544022291e08471a29efb75c16cf8b11eff289b1 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa88aa6874b0930a1f0045a56ad5f2b5974fe8d264864ca225a1d31956cda381 |
|
MD5 | 6e860b669da784090e01f1979bd96fc7 |
|
BLAKE2b-256 | 0086ea61b7c9fb9bbdc164939fa4555402cddaab93fd594c266126bc58aa2c2a |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74cf442dad04dbc6cab13681cb387fe137468b7732ecab823409ce75ddc87dba |
|
MD5 | e115e2e2ddadec0e775edc1cec524552 |
|
BLAKE2b-256 | cc1abc146d1db78bedec10a13cf6ba4516c170947616cd17cf8a417a4c34c62d |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3ad803c62d7eb0696bf4cdba33b8ddfa86148ee57c98abeed11714a1036453a7 |
|
MD5 | 8a6c4c56deeb7fcd375e6befc34b0923 |
|
BLAKE2b-256 | 5d836bdb835f283f91b915ca9ce7faa8099b46103196ae1f50872f142fa151b6 |
Hashes for pyAgrum_nightly-1.17.0.dev202410221729248609-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92cd66f8275ad4f6c6dc24da91066c574c8d85f6f01372d5daa0701f93ad2daa |
|
MD5 | fa831e168f87de91bd48d875d5fbd03a |
|
BLAKE2b-256 | 8a05d33c7cbb9aeb4d237b89aa8b4ee560a5852c50be7db90c02c1077c9eea4a |