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-1.14.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d14d19d979ae51c19f0dad8da15f638dea74afe92c4425362a9395a205db9af |
|
MD5 | 5c88602039f0a5bb4e8a81ec6082e79d |
|
BLAKE2b-256 | 46f4e7042928581f7b283acfe6e4f0dc8ae0fe09d97367570d43efc9223c55fa |
Hashes for pyAgrum-1.14.0-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9b9302da97793dc4a74c2c6b859219cf432c2a92e4064aea6940e102af81588 |
|
MD5 | 6b40af6cf348870d66747c5b28df7f62 |
|
BLAKE2b-256 | db1156bf5eb98c1c14a54d08ae4fc706e61cc63c547c951e6d34e42a0bb06dd3 |
Hashes for pyAgrum-1.14.0-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 951314958afc31f2ed359e810f09e3af8399727f297adc35d9918668c0afb3b5 |
|
MD5 | 96e8968a146949e269db85a3b7c6b6a9 |
|
BLAKE2b-256 | db71094f06f305dfd054288dd4a7005eec9b07fe27ad22e7d4e3f994897b6f45 |
Hashes for pyAgrum-1.14.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f8aa0ba9a4cf24c6bd577147b724785637912e73459d02150eb71b0fe6b64d90 |
|
MD5 | bf626b7ab02d36d0596ba5f36907b010 |
|
BLAKE2b-256 | 99cb84603d1b87c6ad73d28710af711d31e721547b2ad73f287435009e6c1b2e |
Hashes for pyAgrum-1.14.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1bfa1acded32b81a66c8031c424d00eabea88acca1f6e2f34349600b38912a72 |
|
MD5 | dfc416274c25f51e5768b8948813bd0d |
|
BLAKE2b-256 | 43cd52d9d0ce09a8c47d062a7fe5a4ff0c5dff12a38f51899bff866940f7e9b0 |
Hashes for pyAgrum-1.14.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36ed81df7b19df7de8fc79f39ba2c6159a9ca9165fd313c467ed4b0a1c70227d |
|
MD5 | eeef06222079dc7f90a35c7396dcf8d5 |
|
BLAKE2b-256 | fec8ff053ac97a420193f4f1bfce2d7d3f347a886cd8b8360f09cd38684bcdc6 |
Hashes for pyAgrum-1.14.0-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 603168c1dcacee85437b223e3cee3930707ac648234855d0b85f7330894913da |
|
MD5 | 216dd2db7a396c9de1cacfc8fab94815 |
|
BLAKE2b-256 | 5d66fba53c7d66d5369e8fdd27306182a9e38578addd946441905d012eb11053 |
Hashes for pyAgrum-1.14.0-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64b89c40af87b7162b7353affb2296ce2b58681613489dfcbbad113d5e36cf41 |
|
MD5 | d95c553e09b437fbc67ca7d01b7e888f |
|
BLAKE2b-256 | c4cde3f26a8d1de4c0d356efa86a2ff26bae276690450a3d97104d45e950982e |
Hashes for pyAgrum-1.14.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1a4b05b8e7a175c19832ac3b60f06bf83eefce60c6d7bb39b8c9536a77578f0 |
|
MD5 | cd1c19b38b370d615262500d38c39e15 |
|
BLAKE2b-256 | 3b95d3ce768c82df9ec016bbac2387cd31b4a3e26ca11798a3f7f72bb4ce0d07 |
Hashes for pyAgrum-1.14.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88969aee444b53cababdb19d27e29dee48bed400d93a4072443fbc92b33a9d82 |
|
MD5 | 35dc708992d63b86ac036f264fa936c9 |
|
BLAKE2b-256 | 61a65ddf7838d6ed4b466111c906d28b6dbb3b8910e6e1230f09d2bf6b0725b4 |
Hashes for pyAgrum-1.14.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3fec917c06e6b207fc4dd94eb63fb71cdc93b40cde60c86466dbc9a7c9271e7 |
|
MD5 | 9de449d00a1db7eabf67b6cdf786e2c4 |
|
BLAKE2b-256 | 4c30701c485061c575bdbbcfee4695e46e2cdd2788518a3251dc155c26f18d33 |
Hashes for pyAgrum-1.14.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83482d86ee2afb4d51cc1d142baccbc72a08651c023d5642b4abe6b6191f7c0e |
|
MD5 | 58a2137c0e838ca20929c137f9393889 |
|
BLAKE2b-256 | c680227e8848ec6e8e800468293371d61c7e859de7fa9843067c5245ae63a9dd |
Hashes for pyAgrum-1.14.0-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ebea0320c196000f3c5d17365c69abae38d33717ea4857b1e90b3ad024971c1 |
|
MD5 | 6c15bce84cd86937d7718e9c1317a05d |
|
BLAKE2b-256 | abb3758e1379843a6c779b8af2653bc0d12ccfd7bed88d6f90095f76539390a0 |
Hashes for pyAgrum-1.14.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8c644da027110dc46c296a79f37baa193ef1e5140a049384a74b378d8847210 |
|
MD5 | a54bfa10bdb46b7d095b1dbcd294e464 |
|
BLAKE2b-256 | d98bfc28349d62f59d630dc5afd26870534d29a6a0c91257ad627d48ba65efbd |
Hashes for pyAgrum-1.14.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | def6c4960ebaee5a3e48c846c713aaa9f3a1c01362b4688f7e78d0cdfb4a3870 |
|
MD5 | 7575827fd9231e7f56643b380ede31bc |
|
BLAKE2b-256 | d50d842982d83e2eab4394a55499e4db2ceef5fc2e8cd593461e6c37332314a4 |
Hashes for pyAgrum-1.14.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a054203c33f9e72811d01e239b5d2843c2a31816e8acd63727ba120c4ddae566 |
|
MD5 | df05c06a26c4b6d9f1860d6e44acee98 |
|
BLAKE2b-256 | a1e13ec4be8416508b575e06f9536950fec43da02918f1be64a570e78e03996d |
Hashes for pyAgrum-1.14.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6754c949bc77dc4559e8f038205371d6c0b7596cbe3e4ec60fea3eede729febd |
|
MD5 | 52b7fa8e2e0a8fc80cbfb335583c7143 |
|
BLAKE2b-256 | 88f6cb9c92ac4a5f1768685b5b03f87f09df36c4195b20094beb3cb1662a57fa |
Hashes for pyAgrum-1.14.0-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90491fa126296bb7ed380c386b15c1892d5f416063f40f4bc7cc1fe5b174f59f |
|
MD5 | 93ddfa47e3c46339c123766934ee707f |
|
BLAKE2b-256 | 56ab3497d46e2093f1889daeb9142f74e3edeba4b76c6a6d3ffb8e3dff424262 |
Hashes for pyAgrum-1.14.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30833c10761959f651d50dee43e567a109495b82b438e39284fe898d2da52eb3 |
|
MD5 | 50f6fef60605e68b83edbdd988ec8a6f |
|
BLAKE2b-256 | 0ed1e97b73b16668954309f04f303d3983653e40ec5df7677d06b006b2d426ac |
Hashes for pyAgrum-1.14.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da54cec56241223910b654c9a2f7a350d995eaaa2669cf0ffb993f3610dbdf9f |
|
MD5 | 4891bd6819d97aa00320fd19930daa43 |
|
BLAKE2b-256 | e731f4aa4815c6e371bef9355ddb59be78d0081427901857a53f86196d4712af |