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.dev202408161723743880-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cbce6d8ebc2991d539c88747cd6ffaf0b895761c0650fbdb192bf27b79f386dd |
|
MD5 | 5e4666aa8706f66ca3d461b830631469 |
|
BLAKE2b-256 | e96a7199cb5a25741cf8e2fa842d8b84e12cd143b710b8689a2ce890c4d17bf9 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83b7a9eadfab5bdb909473a8f5dc296d812653e8a73e32696e0a4ac8da251315 |
|
MD5 | b32310c48576a3eeaa9b42f9e82dcda6 |
|
BLAKE2b-256 | d8d3796c2dc60ca66d33f1802ca2f1740e22e8267e4d8aa555b8b86aafec12b9 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 413c221e293a82ca79174fb5addb96b988b3e4afcd1e2920ff4c5b0f4c17f10e |
|
MD5 | 785123b618703498f807c6722623fa6c |
|
BLAKE2b-256 | f77afd8b3c7208e1fe8695f1de8a3e54994e375a3f51eae4bdab2d4bb4373aaf |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c64e5dfb51bf0ad48c689a9a064dda9f5b846566dd5d6fa57bdb80b290fae875 |
|
MD5 | 152b0ee871c42ace55e80063ffaa0719 |
|
BLAKE2b-256 | 43a359c04394a3ab7cd9826187f9c62560c16944bc7016c7f3d79fe42ebcceb2 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5129789b810ada900d67ded5aa22918643c8717804d04d732bb280945aa93ed9 |
|
MD5 | 808049ca058cf7256467513a3b34656f |
|
BLAKE2b-256 | 501bc889018d98d65c77e39be3c63cee8aa8aeab017c460d3f19733c03b03fb4 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 209889cc7d0b6e62598ad8f3be6d43c0672087b4513e950c566048ccc730b17d |
|
MD5 | e91a9be6074a21e1a48307e5d00cfeaf |
|
BLAKE2b-256 | f3538730dc8937c17ef186f92dacee2a6bd754838a7137bd15544eaa4e1252fa |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2800caa539e914d52467704e091ddd2d5f5ec7470d478a57eae94c70e3811a8e |
|
MD5 | 695fb61a974a36b1fa55421c76ac5f42 |
|
BLAKE2b-256 | 1024eee8b4b7a49797f918ae023e5181f4d5a96bf88bace2e711329aacd0f397 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb287341181d6259722697a2504b57595086be9871a19e6d7c26ff43dc05eb2c |
|
MD5 | 840be162de2c5ecc9620f8a2ed86166f |
|
BLAKE2b-256 | 4f4fc79a6e27a22b01e88932ce6fab172ae2020f5378966e99a06de1b694f04d |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63442af9575af296b5514ea723dee16acdd30f3ae851e7b23ddfa2b53f53a139 |
|
MD5 | d73978bb894578590af9fc4ffc5b6c83 |
|
BLAKE2b-256 | fc769f71c2f70e7b58008353a9ff1991dfa0e6b4a1348a781b037f975f7b8e3e |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d9177ddba0fe14967d35072c4415f9fd3ac7194e5604c76c6e155a19141131b |
|
MD5 | 3d20b8979f3c15ea15781a1c45405252 |
|
BLAKE2b-256 | c6e693d269ee68ef8c9cbc56d809c1a6445f4148ac8a2bb2bfe97770e18ff8c8 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cff171105fe2ca2c17a5be559ee6d5fa3e38f2724aab23f5c59a55a58348f7da |
|
MD5 | fed1d3d8a4da8b612c0066fb843e5529 |
|
BLAKE2b-256 | 82431f6fe1370a53aa86f30c1e67441b926d36e31581f82aa9e00547df0cabf5 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a6f0b087184eb8c20d8ecfc36956cc55f8f4d831394ff5d50901be8713049b9 |
|
MD5 | 1343109ea49502a661d6be4737a6880c |
|
BLAKE2b-256 | 23bb710257d723ce1e59c08b5ac24f531fa032cc9052003814d9e5cc58328a76 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fcf7d1372aefbc2de11273ff0f43999e79d8409b3255faf84b5f220367db235 |
|
MD5 | b0c59a791e50e6acaf7d2e784b46203f |
|
BLAKE2b-256 | a8623d45d1b2297ea365ffb808c6cb5a0e65ea236a68a3042366e575359a4aa3 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d482cd4c93986251917fa16ef1e96f42de428079b4d83e0dfbf4f41c4c641c81 |
|
MD5 | b9f288c6d8ae84ca06b635a6910d43b7 |
|
BLAKE2b-256 | 6b1686badefb0d12a68169378737075e2a664c88c1fa982e2dd380f95800b886 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5eaa0f04a4b8099dbdfe67ef4c3162bccd7fc43101dc0dc25f340a9bc725d943 |
|
MD5 | 2dca091cfb7636dda8de9d5a7dba3d55 |
|
BLAKE2b-256 | 1ed28f363993620cb5c9a8fcf17d5c6a7e92ebf7e31cd7f95d3d2f3cbd928fae |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 800a4511ff937da60aeb3b7665828ecb133da5b465897180fdd752fb47191dd5 |
|
MD5 | 7587b1d7a50b335870548d93d73c3aad |
|
BLAKE2b-256 | 98b3a1a0ce51ec75e155789b20a14c3ec805288ab11b7d7ad1d4fbe872bedaea |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15cf9ff510d0e13da269f891adb5d5dd625be6bce5929baeb47f56f64dd84a08 |
|
MD5 | 77fe9143bd0b36992228923e67d8f499 |
|
BLAKE2b-256 | 65bb9c399c5d38ac8c3da5dff44c17dff9bcb06368d351d568c02811ba4b93a2 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df61ac48feaeaa32ef06aa815c5546272eff82bc28dd18dbf9fe1eb0248ceb20 |
|
MD5 | 6dc35a2266ac463fb1f62714c8e7d502 |
|
BLAKE2b-256 | 3840d9ce8b123bb7037ae0be8bc0fb735fd274fe52d9db5a8ccfe00777f40419 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d6016be7dba25152b8bbccb78007afc6cd037db561d9a526ea9497feeb528e5b |
|
MD5 | cdf1c0034da5025f3f3b7d6236d6b432 |
|
BLAKE2b-256 | a2b60a564920ffe07ff8fb7631f47b68b6007c18edfeb89356a3361002cad2e5 |
Hashes for pyAgrum_nightly-1.15.1.dev202408161723743880-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 73a828a620742d1608133a89c690a60e8bb7e7c17e466d22b2e7337228374bab |
|
MD5 | d13a7e1c2522fac9f8802cb5c739e0fe |
|
BLAKE2b-256 | 0adc00cc9df55f57007c1ebcb9294150e90596ed38d6e74e5f123b87aad6d94f |