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.16.0.dev202410151727562243-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ba0b6019f89f7098b009d840b25820cd84b5211f4cd2873093b487174115969 |
|
MD5 | 07f22b62e0ef8ae8a80309c681cabeb1 |
|
BLAKE2b-256 | 8404ca27ecc15de1dc6d6a968b9d15fa40bf32c882c2389ca2a2156016f6c1c3 |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp313-cp313-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0c9d6d86386dd697e4f33371ed67e4ae0c4dc13e089021c94a643026ba194b2 |
|
MD5 | 7120aa33c155e008bcca2a9edc2b605f |
|
BLAKE2b-256 | 4251d2cdc44e6dcf60d2215a0d24423444995a79999a7930d3fbc2c9a1cafd3e |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp313-cp313-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3466e56285d531b9e7cff86f1770dd741124304e9925c952785e723fa7869d1b |
|
MD5 | 6f2c1b9e9647dee599dbdb6fdea309b4 |
|
BLAKE2b-256 | 5924a553828790429a1629ae0420b77eb33f99aa63b3110cf7e3e7b1bf94c5e4 |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 965113e95492e2a0035db936e35baceb3d3146af65a3ce0b6b3be55d2d496271 |
|
MD5 | d95a2c2eeb129630848b315d28d70ade |
|
BLAKE2b-256 | 3cbdf32fe7c777188d13480048839e5c96ab584f3c57b321329e5b18423181dc |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00a3e84f9a1a8d862c6d7e96350161dc4b5651a5c2b59dca68efd0224bf83ee8 |
|
MD5 | 14f7b4764087ae26c95ece381bb83dd5 |
|
BLAKE2b-256 | 1995c727dfc5848b8920322ddd194cf8a8912f865e04cf43864f1bd0582d1397 |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 334290bd1c5893d2cf65e55f77cfcb2142faac3f2983677e8bd240f972c1add1 |
|
MD5 | a88145ec73153ede534680e5d75ac9f0 |
|
BLAKE2b-256 | 3317e70273f920f5fc27f2a77b5ac1ba6d9a8b2ae311a6ac0fd55d70d4d02ade |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2efc78707a32c0d9bc2ac9b41fb9ffd2a16b7c72d76ef7f65c560b8433d1fc36 |
|
MD5 | 0233f5a73e39c552923869c6cdb6f86d |
|
BLAKE2b-256 | 7b2d5fd9ec51badce993256de3aa1d124622c1457b3b23133053cf8863c369a6 |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57ac17e5413ca6c0a48166d4acc82ccd96ea9960c111628a419e9bcc9e616755 |
|
MD5 | 288bb00fc18c2542ee05790b7a3d3d3f |
|
BLAKE2b-256 | 103487ce2d602a2183942a84e304b747c5e0107d7e1a699910779b553b589521 |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20a993db20da307f208df5fddf159139fc98b22fbabef53fa5012c59b8d0b537 |
|
MD5 | 987054892642d1ce25ad8a8e935bec2e |
|
BLAKE2b-256 | 7ec07a570002984027ba1634fd66a233755b89ff35cf0f4e388f7ba0d88ced6c |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 929eace5b0227e16ed09e00a11cb66d2382bd12b5555e2e81fe84a44b9aaf122 |
|
MD5 | 35d14b3f37d5f27277cf3da15d0201be |
|
BLAKE2b-256 | bf2c994ee71b9131e670b3b2f2c99c724a81bc9ad14a427a494d105a38025407 |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a4bd87d77208bc47c815a172ccda85b31c1dc6b708d98c1f916f94d642e735d |
|
MD5 | 58abb9c2cc2323d5942afa650128e4a4 |
|
BLAKE2b-256 | 65f823d5778db0fd1d2b0f42fa80d807e0f6499580c540aa44d33f4e04885b09 |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b0d9968ecbb1a6138e24ea1801af7e128bb8fb7757caee2f0d1ab3803bc9a77 |
|
MD5 | 3206a924daa7eeb29bcf9a7fbdfdb990 |
|
BLAKE2b-256 | ce0e6758ed8e2b1e154876b96681dfb4652f7e20e550bf4a45d8319b216d55c7 |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 353df59b90755ee30095557ea3831a43f0f5b65d67ee6235e60147f4805998c9 |
|
MD5 | 7995d177d2bdc57cf3cc8a0984e1fede |
|
BLAKE2b-256 | 528d8134bbe3be978661d72a572d2a4d81401cf95337b012c31d5013e23728ee |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eeaae1ba205e107e54f6f6b751cc42f338893f20934c5ca8bbb97b1c6ad55216 |
|
MD5 | 79ae3f1b225d7744a1536e98dd462f46 |
|
BLAKE2b-256 | 89786aca8151cd7fdfc41c7b04cc1545175b02df78a5d7476adaa08bbe74a62b |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 803d4c5c901ac85f5e4fc65263d2a2640a08f801fe206046b1838d599644f960 |
|
MD5 | f86ec8214bcfbad5498296b6d17edce8 |
|
BLAKE2b-256 | f5061e5b60520ad324f269e2f4c5a5631e699e4f17875695cf94329085d2863e |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83d5e134f5a68db98d6ce69469e565289cff33f0083b3df677e9ea4ee7a018e1 |
|
MD5 | 79583f1ceac7ced9e20d6876fddbfb14 |
|
BLAKE2b-256 | 0eb6ae1da7e6a2324ab65b38e2d7aeb191a81b79d3ae56cbc22a720dfdc3543b |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7317ef78280dbfdfb666069e108455136b8a7f6ff808b6084c950b42bb9e6b4f |
|
MD5 | 23232803d2e17d678c9bc3353d3512a6 |
|
BLAKE2b-256 | d68996c5911d9132d42a0d634367a7582d90d9d7a0aeb15b97a0bbcbd213d6f4 |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fee1ee5b9f180ce8f2f1ac6cb0a635def39a586ea62e32c90872d657836d5d32 |
|
MD5 | 42b27b130b0fb9dafe90ba99e2a5b4f8 |
|
BLAKE2b-256 | 70f757a15bbb2e691d189ea2942495bae8ca993e06cea5b7b2291594aeba968f |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a94af24da299c4088e94e3132453ef3e04bc4e4d276432fc2a91f6ea31534d69 |
|
MD5 | 0576eddffc330ff7550e7b1985e319f9 |
|
BLAKE2b-256 | 4b49dada153d10cbc9a81f55af72b14cee1ecfbbfcc8d3d4e7cfecb9685edded |
Hashes for pyAgrum_nightly-1.16.0.dev202410151727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50ce29487e0829e714daecfe525e4d361b2cdfc1e181d70b264fa735f940aaaf |
|
MD5 | 0b24adce4c24fdbfaba25e8b0a2cf3b3 |
|
BLAKE2b-256 | 130ed21fc19d2a0a4353623d41a865b6e7229a0ed27fb2f2caf7084ccdee5ccc |