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.dev202410041727562243-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99b0de4fb61139eef9c4adb81131cc6c6ba53a3d39fc5073a32b7de788ecfd4a |
|
MD5 | afc64ea753364e5e57acbbef5cec88f8 |
|
BLAKE2b-256 | 74cf188a02dfe4783095dc8761120dd9f14d2462957d175565866c63a86aff6c |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dc3e89baa78c7df572c893481e56d609cb3acb0781e228d660a1378cbef2390 |
|
MD5 | 76d6d714664af5a2e97eafe8c8151152 |
|
BLAKE2b-256 | 56777b326a793d880fcddde6d8b5dde9e74f3b7501d08a148a0abb2760b5364a |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71efe2f7650957799cbc6951aad20437737cf93aa481842bd3d0d5145e562297 |
|
MD5 | f77772442f73aec0dfe80d9fd64d93dc |
|
BLAKE2b-256 | 443b79ab6313b32a194f1a93b6a157b87523c256052a299da8ddc46fd775a958 |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af3cdd004600be513395e652acc1478b5d53d56fe7d0536eeebc8a6dfe32a26d |
|
MD5 | d4f9df4f75be1b3684f39383392c1939 |
|
BLAKE2b-256 | 5dbc0e931bc10d11efc3ad50a83c1a0a48c0889e3bb87446b9aa5fefcc597bc8 |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6616607ad0364dfd2dce1d041a2ec802b5ac19a102ff4c480e814de319afb82 |
|
MD5 | 65b8d04496abef6dd02f9e28cc1affcf |
|
BLAKE2b-256 | 92362294158343abff8766d62778a1f5d15199d4a646ede47de5488ec89331ce |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bdd6c4ed2d1e8fec77209d5c139dfddca52fe1144994c3598974c93d0912a4e |
|
MD5 | e3a3f447cd3165388a684cfa59639968 |
|
BLAKE2b-256 | 3534c7811e66ba7b06b8dc8b960b524994b62a9d9e114835ab7a788dd2b92099 |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 231f3340e676d4316ccfc2a366eb912ab645474baa104001f9bffd1abe707847 |
|
MD5 | 172a67776bc603626b0bcb604ff014b4 |
|
BLAKE2b-256 | 6e2552ac98966326d2df1b616a034734ef44fc8069777bba6114fcff07169825 |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8522756a994bf183dfd3bee02ab056a4bd44eb07e85073fee660c9bf2932032a |
|
MD5 | 6bd2612a02c6bcf75712257de98621c5 |
|
BLAKE2b-256 | 78a37edbc04bdc55ce5d44ab76d31e208f1e52aac94706b22026fca937e24385 |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a42bd8ffab55ce0983dda25fba90e54bd736fe5c4057793d26032e177c9696bd |
|
MD5 | d192a30d234ce929db67172720ac4712 |
|
BLAKE2b-256 | b61ce1326fb928ec544392e4345cbd3380487c187e04ddafa01d3dc721883df0 |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3ce38acea7db78b073b6445170fc7467a64443f847ef8b764f4caa843ab865c |
|
MD5 | 1cd2405822bbbbf57682b0e63f10bbb3 |
|
BLAKE2b-256 | f0573e8c85f4c2419fa4f431d7f80551aac7e7a1cb7c551bb749c1bbc605f354 |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79b2562ec640ab03437978453fe93d9e4635dc329a4cf863264489f0377452c2 |
|
MD5 | a87e20ce8102ba6879c8a9d3c183349d |
|
BLAKE2b-256 | 91c348901507ac4dbe9aa8a8c146076f81294bdd46996d0f258c81761dc0ee0b |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b49c2a22837f982ca05436f0f914067f4911ddb3178573111576aecbaa8038c1 |
|
MD5 | 06b356d795ceaeba162f5cb3ac1151e9 |
|
BLAKE2b-256 | 3ada8eb012411532ec2feac51774b89d853546cd5cfb6c99fd8869d8aa25e79f |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cce393dc4247d99027a6eb151d639da7aa8fda1513815807b6f40afdcc7a0afe |
|
MD5 | b0f480167e2dfb6fac38311189974c9a |
|
BLAKE2b-256 | 8671e106ebd1dababa78848e78b8f382b88089b1ba52e2bc010c6ae954f2f57f |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba16f84a3b6863badca2c7cfb3e382253c91d9d72e9bcc2340fa0d6803ad7397 |
|
MD5 | f1f2793c9db6d04ee96becb8573e82ad |
|
BLAKE2b-256 | 67b9ddfb9e81d8f4379c56a100d5ba4e86bacacdc5cb2f2b43791673bea7a45d |
Hashes for pyAgrum_nightly-1.16.0.dev202410041727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0aae101a121e21835786f3e9c4eb65a17ebd53049f6de427461741eb249dd836 |
|
MD5 | dd9d124295fd14d97f49862feb1da82f |
|
BLAKE2b-256 | f1fa21190363df91323b38f6a53ce10ab6c0930e7367935a6c79bab3d5db2e87 |