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.9.dev202409271723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5b906cf78eb5bf390c78fb19a0515bebd83dac9c06b5608086063ffe403cf2e |
|
MD5 | dba2e89cd86f673f97447210b6aca59d |
|
BLAKE2b-256 | 768e2b6ebe7bfa1ed8565a19a56f8fbdb313efb5e2bbc72a0539e667e63131ec |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02e84a2cbe4f4e7487ed2cec554960aca487e620a87fcb7a82c7853ee0a3c431 |
|
MD5 | 2d4216f45dd35f05e300339675a0b72d |
|
BLAKE2b-256 | 2a411945fc43038363f8e15a268ae6308095da7e4a51319d4c8ee2b4cd5396de |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ab9c891d8e9f0dd053c4e06af69683ad8b67ce309a84a1729670796e551debe |
|
MD5 | fb6cfa4d6da3d815b959a008eba353df |
|
BLAKE2b-256 | a966d28b658cddf779ff8da5775026eec6d52bc2a0400dd7dca71502223b4f57 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a47e85ff55968577bba0555fe5bcd41e6da2eb180a0380923443ad4eb9e7a038 |
|
MD5 | 7ea74e8127392c62991411eb6c487106 |
|
BLAKE2b-256 | cb2869139c2608a3c9428c9bf15fa88ed6234c4c86bc76faa1d393a22c0a432b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b85016a105699ba5d08b529def1830c49950ff354c973a4726d43f70a8dfb0e7 |
|
MD5 | cbd842d554b5e5bcd6837232b917870c |
|
BLAKE2b-256 | 7e09f5f6e7fbfdaa78eaefbe39a0aadab0e7ecee43d8ee2b3ff1c583584f8d51 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 93ae678667771ca263524d32cc19ffa8c39d93b8e31d4296e386d9f1150eec3c |
|
MD5 | c2dac4b312ada7df6af8ef239223f66e |
|
BLAKE2b-256 | 01ee010d369f450f2913d6f753cb15eaadf0bc34ee2a982e81a711607cbccd0a |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71be78dc9aa2cf975aec6fc468098202dcb1d46950444bbf7f24c0f56f2764f6 |
|
MD5 | a46103dbfdc9eba6650ba45067843b10 |
|
BLAKE2b-256 | f22b6845927cd8c434da21a96a6b7a401016d32515777c5ebff4bd553666e75d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e030ab0fc976c31fe5b0ac9f9ad175d24e3eca591374e406017608087db8a69d |
|
MD5 | 56f9ed68aaaa9344bcd8c71e3e944f77 |
|
BLAKE2b-256 | 66b779d6ee1f220f8b7b13a83a60fc24916736bb1ccc2410767a13273de07828 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 57f3a7b62933a262cfcaa67eaaae40bea5a0c8a0e052395c876121c01b04b7fa |
|
MD5 | ff5d21ea82e566555ea5d3a6ba3696a5 |
|
BLAKE2b-256 | e2f74374bc0ac6d92722bb59ccc648bb0eade539032b40dd58290f04b60f6942 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26f8626e98d76989da8e63d4ff7f28d610f203e35fe2385ed33aa055cf8c212e |
|
MD5 | f9af22e59330b61b549b4f349ceb044b |
|
BLAKE2b-256 | dc5fe42019506ffa07da799fd44ec5af935c325bb915ab3640d50c700b7ed96a |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8dddd4b0b13e3fa3137d54cc9916d0060de7f40e1f22840f49419c96aa9d475 |
|
MD5 | 1bd81df00bd532a5f6773e84b8dfc1fa |
|
BLAKE2b-256 | 43327d795146ccea26ec52095c61ec3c93074fce644ca44bfbead734d5955833 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00a25542f84bb876b702442c7a40127673f415e23dac77d8abb9c7b359beaf51 |
|
MD5 | 89d563866eaf0be62f2840a82f0359b0 |
|
BLAKE2b-256 | 7baa925a2a31ed984f55d45cea730bec5b243b07fdb80c1ab7be5e3ecc1ce0f5 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee1c3c0b166811d89a2fec1bd1a77f8cc75a16bf4bf3203b360ea4765045e6fc |
|
MD5 | d05f7363e88a006f9a9ef4dcdb4520ae |
|
BLAKE2b-256 | 2e95ccd93964cdfc178094196447926ff13489a0f558100f825493fa53cb82a5 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ba517e57e37d3ac49a67ca30bce2f7dcfa24e3cbb95014b3edb93c584dbfb5f4 |
|
MD5 | db62c21aaca850a79d806076b7ba808a |
|
BLAKE2b-256 | 759da899c512ad5b029900f6c3743e9b646782653f7ecdd0aa771152abe8e7fa |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409271723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cb816aaf39ce72893d7c761b67d67cc3299384a0f2212beca846a75fe2630ef |
|
MD5 | f2afa7b38a94c40141d464c1dbeda563 |
|
BLAKE2b-256 | 6b418e1e9183506217339d97a17ca086ee527f1a1fffdbad52a6c467ff7e2e35 |