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,2023 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.13.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5096fda1d858b029fb3c8533bb725f428016b30c1d1df9aa955d5a6fe3b662db |
|
MD5 | 7ff19780a92799aac61e0b74b9bdc866 |
|
BLAKE2b-256 | 757aca12d82d6981ba0f59a750e00b47703141284c2efc0f649252a86fc5a869 |
Hashes for pyAgrum-1.13.0-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2a6955250aeabc601f8b08fcc87a66d15383c8742f99b94a63ae6a46fb5e9aa |
|
MD5 | adb36eea8ace05e9ebd360f9a53bb7e8 |
|
BLAKE2b-256 | 293c67983f3e383e624382640c234afca812c06cb00dfbb6976db643e8388501 |
Hashes for pyAgrum-1.13.0-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c78ccd917525ca6fc5dd05e521f6a8d78ec12d8455c3814f7ff29a23200cf088 |
|
MD5 | da0a791cebd3e9dd919771027f9a6cc6 |
|
BLAKE2b-256 | 27475458875ca4822ea4d0e5295de7929e87e42ac2eed908d5de222852428355 |
Hashes for pyAgrum-1.13.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9173a89b67a810b537d15677bcf9ffb340a55b31ea03c7e11d9b8e26b16abafc |
|
MD5 | 17c5692a3a0358cd4b6bfa796c21ff6d |
|
BLAKE2b-256 | e3f8ad8c4a7e71af8102d3673b74974f113efb3c21959e211097c17be273a342 |
Hashes for pyAgrum-1.13.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cedf890eefa2b9fbb8f4e996bfad9f1f827e9478f2be422687cfcb53421ac677 |
|
MD5 | 44539dea89bf2e76b56b58ce6a2a4fa0 |
|
BLAKE2b-256 | b3decc438b03236809ee4a4078e0edbd6a05f641e1320ae32e61a27f9c307141 |
Hashes for pyAgrum-1.13.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a8523dd2a686d06f3b20ca6fe393d3f1b6f6799f40f3645c8a591d35dd90b82e |
|
MD5 | 736d3b9b471ff1a67c66d11603af2993 |
|
BLAKE2b-256 | 40c8b5fa91240eb0e66e5f1b2cb6a62c5f6a041e73170bb79b805855ccedbdc4 |
Hashes for pyAgrum-1.13.0-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12d7303216a4733584241425730dce3e4ba3b22ab4d03b9b6d22c0f7a9a999ca |
|
MD5 | 31a21748e8d08785d85569132d0b177f |
|
BLAKE2b-256 | 50efa08a7dbf21a75e2712ac50b42d916163d414a9e886da0536a170076c8f92 |
Hashes for pyAgrum-1.13.0-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57cc2a319e40a6079356657ceb26bc7d5ac4a08f3a63cbd6c2a1b713f73666db |
|
MD5 | d4a65e518777782c99a572f681168d23 |
|
BLAKE2b-256 | 902da8d583b88be56d23cc06c499e03b79543b4ec679b1a02ce7358e7077658f |
Hashes for pyAgrum-1.13.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1844f8cf555d38148b313f183b89e31737a8a954e035b9810d18aff0507b9ede |
|
MD5 | adf98f1d3117b5aaafb0589333682ced |
|
BLAKE2b-256 | 7b682b1508c3bb0386718e8fc4d3acdecb48328d87ec0e70b7c2973844537f56 |
Hashes for pyAgrum-1.13.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf0d1c9b9059e5fd0c8796400187abde18bd3dfd575a750ae73b012c87d78f93 |
|
MD5 | e3a068bb5402c536f34b0fac28e9dc1d |
|
BLAKE2b-256 | b2826c37ec9224956c76b6a5fab7acd5f92c07a69bbe2e0eb6c5d26addc37e8b |
Hashes for pyAgrum-1.13.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f5944422f7b29f012d30c3964dd9bbf302b0aeed7d9e0bc4dea985ae72c2de7 |
|
MD5 | bc601400130d380b3c2b6a99e824a6d4 |
|
BLAKE2b-256 | 7591d264efc09fb426ab02ee04dddea5952864e1ae806ac70c000b9ddc5fb140 |
Hashes for pyAgrum-1.13.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6dc0cb13dff5923e9ad2cb428b28c2286c20f31a458eb232af0aca832dcac2e |
|
MD5 | 0fd9c585fa767434be189a058f4aa2f6 |
|
BLAKE2b-256 | d89f47f15be9247c309719c5b64c486918187a42b28d241e2483672f31a77cba |
Hashes for pyAgrum-1.13.0-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8aab242e25bb9d549c36945a44691ae48a85c4bae6147678bd8bcadcfba3d2f |
|
MD5 | 4d4f69164c88468337713b45b8897e8b |
|
BLAKE2b-256 | 7d949ddecce13fa2041d3d37e87fbb7c2fa80b5f81b0adeb487391f88c3c5648 |
Hashes for pyAgrum-1.13.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ebc9b8a0141148933c20842d29e7e4d05f62649a8b591f0abcf7ea2f9dfd682 |
|
MD5 | df283ea7fbd52f2950376f6c329ca389 |
|
BLAKE2b-256 | 23cdfb5b91c0fb727c66a84f04abcee5c8f5a3e88ce6d2ede2ebc33b12419ff8 |
Hashes for pyAgrum-1.13.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a56484ec44b6d2e3016ff75687d5da53224c8e3df83a222b7383b384bd4b14c1 |
|
MD5 | 4427f62ce6fe17b4733edc3348a20ec6 |
|
BLAKE2b-256 | 03f5b8cd716117cfdc24861d90363041c20d9efbd6bc5f6a7e8a73095c9636e4 |
Hashes for pyAgrum-1.13.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d535eabb303769f4b11accf83abd7d84be440ce8d2720969216e8149654077c |
|
MD5 | c346705b2d36235fde51b5aa1a80da69 |
|
BLAKE2b-256 | daa614906c90b04251685ec52a4d7b5a7e709640a9025cae9f70f3838c08773c |
Hashes for pyAgrum-1.13.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92b98ec0fe1994c365d600cd56dfc82e292a9e47ea18e8835d6f7748e1ee69fe |
|
MD5 | d58eaa36927d9cdc17063f6885ab7d79 |
|
BLAKE2b-256 | d5fd82b8973947cbe1b3293ae1128de7f03cd0f457e334908c733ce6514ea6db |
Hashes for pyAgrum-1.13.0-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a75ac4f941b37e974610f2bf115d334d074a4d06a4256d056a28667ccc1d8104 |
|
MD5 | 1a06f99988fc9b282981ab7d3f4ae5cc |
|
BLAKE2b-256 | 0ff0fc7da4f5854ca75cfb89651fef2fc32ebbe869031d0b7e18323e346dfd14 |
Hashes for pyAgrum-1.13.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e94c119b5cd714cbcb1ac3a3701a2591a45032682f8e28e83574362b8dad964c |
|
MD5 | c8c1947cddacde6cc501393d46157686 |
|
BLAKE2b-256 | f20339039201d66eed1d20231af26a506687b8a739aa0382de1d65662b7fd6a8 |
Hashes for pyAgrum-1.13.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 163cd44cc26d11d512342c82201ab70732eb51f1c70ae88242a3dfca43d52bc7 |
|
MD5 | e86f2b1ab278728f0b5959c22f22e3cc |
|
BLAKE2b-256 | b96191dce3ef0c7400ca92d7ddb7689d0cc8742d79786552a9f29e6d577aff74 |
Hashes for pyAgrum-1.13.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc2a619ee727eef77f83ea112fa8efd4096ec09820195b30a25de499bd2b6f93 |
|
MD5 | 2e6832a455586f7432d55b5f607b47ca |
|
BLAKE2b-256 | c6c190e8debabcf3d189afc856eb4b66349f4a34821a6b7857307c612c6dc527 |
Hashes for pyAgrum-1.13.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fae26a61e8129a0d91ac6491d36953a614228724aba885a45b05c92f848f6bf |
|
MD5 | 330a57b625f084e7ebf7bdabc125dfa8 |
|
BLAKE2b-256 | 43b305a96d126056961e160315f9467c2d31f20860d4ec108b402ed8d0bdcf67 |
Hashes for pyAgrum-1.13.0-cp38-cp38-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3af9f626b78eb21553dd0e930635b4978ff1f0262385e9138f1e8f1cf44b73a9 |
|
MD5 | ebcf3e59e7f8fd4a388bc2ec19c54604 |
|
BLAKE2b-256 | 1938a4d2ca939299817f823027da4653963b75ed229c23d775b26e0d7de25e63 |
Hashes for pyAgrum-1.13.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d79a781a088fab1483316bf6553e03d360f041004cb9cc7c40453372524cd84c |
|
MD5 | 09359fa09df078fed0a2a741e1e4b94f |
|
BLAKE2b-256 | 55e03e6324ebeaf837271eaeb119a59453c3cf637ba123c2f9bf7d783d85bc02 |
Hashes for pyAgrum-1.13.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7617a8c49f0c9ecc16177585d7a1d6c86a65a3f9a230469e5290373193e29aa6 |
|
MD5 | b624e7136aaae1d89e8c6282c12a9522 |
|
BLAKE2b-256 | 4e34341d7bcbb90efa6fb1a130b8a240e4a181f2b1ed228200df900a13475104 |