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.dev202410311729615378-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 395769159b2badcf64073a4b7655110f073940434a4bc6dead1620e155884636 |
|
MD5 | d804db2899901cd8b0cfecb658512679 |
|
BLAKE2b-256 | e5b4eb991747be6306331ce39316b09ceca4ec669369e30c72962266c99fc956 |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp313-cp313-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 868b3ead0c7905355384cdb1badc89181698f8ef03364547a4eebeb06e021a25 |
|
MD5 | d9c26bb4673a5750b179039b263acec9 |
|
BLAKE2b-256 | 385cb0dda864775074a53b5a52fa46c49b607894cce1fb24601b41efe3465244 |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp313-cp313-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 700e7468a67db70955bcb36047706a2b6cbb60fcd92a40f302d84b78bd665070 |
|
MD5 | 47a491a218f6ef23cf03a9ca156bd313 |
|
BLAKE2b-256 | fd5541941c10aca9d3faeb9ce42fea2b87c59d91759a2c6782cfee056807e984 |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0e15ca823409986494bdac608e01adcf789db76934d1561f7cc507d6e0d707c |
|
MD5 | 5b69cc7431187efb65be10ddc4bc69a9 |
|
BLAKE2b-256 | 1503e5b0369c3802e5141b004ca7e238efd90166d46f6bbc221101173d3b8a29 |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9342c6ba4c57e89647dba0135b32f26e320a2890640bb2854be94a9a2c4571cc |
|
MD5 | f01820a8a62d5502f9792f1f1cd7971d |
|
BLAKE2b-256 | ef01d288594304f8b594a780806e152d4bd97a2e0672ea963ce72fc9e312b9f3 |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33be57f7846c99b876e0bb0e15383e9caf2f2b8e3de41d22ab93a6dc316f1cae |
|
MD5 | 33f8b56a1a9322e792852131bdd24c99 |
|
BLAKE2b-256 | c455a852eb88dd8956e9f4340d7ac1ecd20cbe52666a99898ccbc3b86c327575 |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e355922f9afd37172c9cc0093814e2a7dcdbc36a8a5a14a5594ac677cca4ea70 |
|
MD5 | 945dff646e5c435a6f6571b6cad7069e |
|
BLAKE2b-256 | 905837ae0200ce8706a246e82cc532ad9fa85e7226c5511dd8ae4483fbab1adb |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d454446dce1ab413e522e8944efe62cb46c2a1c6565b3ff2308144e0ebad63f4 |
|
MD5 | 461aa03a74f969e776e37e7d412945b3 |
|
BLAKE2b-256 | 440203869b252b06ed17c3d6c0190c5bb4d382384fed2c0e74424f7c5ab805ff |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 072672119891b9c9ad2a8bcd00b61ac5c98d002a5ebcd4f9a07e17837c5dd3a6 |
|
MD5 | 40fd0762d0e9ed464da65575de7aa702 |
|
BLAKE2b-256 | cd8b0df9c7dc9450157f7b5bf9a665354a0ad51d0ac8555dd7f32ea44bdf6021 |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23c287e74c8764a66d4d46dca1af579a24649e66de9268d8e572c00d3e3b82c3 |
|
MD5 | d9500171760446e36e3078a0e4a972fd |
|
BLAKE2b-256 | 5ff74ec1b616b4b08e3caeda7ba3fac64d61650ba9fd81384177ac12ca953380 |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ce26b90fde81fc5fc833cb2f1c86b09fbdba4838e71eb2897311ce865df0e5e |
|
MD5 | 102574e15aba2b51b3c36f2e19947a7f |
|
BLAKE2b-256 | 910925869276d1e94a7ccda59362de183cf78d5a1c9bf3af3422939a438da440 |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41e7ba9a55dd28bc802d60ae8ef4e7efe8bc0425be20876cc0b24330e350fcd8 |
|
MD5 | 0240294669889e0933b2459588268130 |
|
BLAKE2b-256 | b00fd5de5c0473c3d227dbfb1b75d9d8104cc3592b446152cb98cd60ee9169f1 |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac850f97d4a94e3da3cadcee3eb107bc8066bef789f2a88330cdea93c1dec902 |
|
MD5 | 20f2af86073a3b2849d7542e050bb248 |
|
BLAKE2b-256 | edfbebdecb54f037878895bb18bbc817397344f9aca240b7394cd8e90a42414c |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac79d0d3bb2d57dceb651bc4123f95e3c7ee06d27a5dd9c378038168a05f5aaa |
|
MD5 | a25cdf9abc13a857237973a20ec870f6 |
|
BLAKE2b-256 | 66f15237ad419fd104b7f01eb233f886f147a7167327db4ef99f21a0620b7d5f |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75a7a9526aa461b00b45ef2a4f5b5a0878991bed2e064ea4ca7c39f8dede8f3e |
|
MD5 | c5a2bf22fa74c64935f835a41e3767a6 |
|
BLAKE2b-256 | 95207a6816f19a7f159770bf550645607466fa721d75d29d0820eafd1fa4fc7c |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa5456d5be7d060d7b047b48939e1e63ed1ac781a20b0e2744632f4c9d91cc2b |
|
MD5 | c3d682cf0cfabc79051229d790270553 |
|
BLAKE2b-256 | e846e476eb58393b3fdd4dfa74b553543142bf35f27657855d89d0d6063b47dd |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffbce75f147c3d96760922454861f84ebf54c4ad4ae24e65f5e0a8235fe6ae9f |
|
MD5 | 4725b1b3ad34efb7f4006fd100cc7518 |
|
BLAKE2b-256 | a05833bc7bfd9fda74cfe64e466801712441456b3de44482ee2356875a9e1f10 |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c337fa0eae93f8924f9a2329889efb156dd1f603070fac0a21d859b85170113 |
|
MD5 | c998d8cfc0d1417b4dcf53d21c6396a0 |
|
BLAKE2b-256 | 7e74f85d41ab4124d30feae00b0acc82d4f166011354a0d202f1c151b7bc8a8a |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2fdc337bc80af5a0733174dcbe806b894fab5b71002df5d0864ee750137bf42 |
|
MD5 | 0cf8abf561c79ed0c6c9b7381908ef53 |
|
BLAKE2b-256 | 5a5ffa0565069a5672156a6c82aaeed6f4b825687786a9098e4801ab72d5c00c |
Hashes for pyAgrum_nightly-1.17.0.dev202410311729615378-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79582db164320cdb7f7de198cbc394e6b9b3c7cd61be19095f6252c987759122 |
|
MD5 | 0f9bf72c86fc83a249b691abf0aacf1c |
|
BLAKE2b-256 | 6b0dbf12f02022fa87b1724ee31bc53d79bcb2095783c8927d6eb8071adaf37f |