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.dev202410051727562243-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87a2d5fd7f243ad4a8422155943767630b67eff3ff7b9af1c1dbae71a518e3e6 |
|
MD5 | 6e0f7aaa0b29bb416f52e3ba2ed7528b |
|
BLAKE2b-256 | bd123b978911eb4a86a73583a402ae5a3474f4ee3a4817dfca422d909b6da4a5 |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af529d6a802af720b3d5353d175127e76cb9f9de50d78fbc2a87c87ae18b7e52 |
|
MD5 | 6b66992e713fe7d897be40f338167f5c |
|
BLAKE2b-256 | 3562e13f108c2816e06ddcd67005632d64c05acd5a0f77f2a07c75f266624af3 |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f23a70c1303e2293f694abdac860f7975d09d2f2e2f08279d0ccf768dcc69d2 |
|
MD5 | 0bd2e3bfd31491f91eba14311ed7fec6 |
|
BLAKE2b-256 | d717245901b5390bc73d58c4653a6f841406cfe2457ce47f18661de4dbd603a5 |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de1e8593c41241d7ada5468330ecd75b67b63ebe6f87e9e95774f21624fb6714 |
|
MD5 | 81c14fee07adffd55fddf9f08578b190 |
|
BLAKE2b-256 | 0158bfe0aa373c8b66f582b090028f22a70af2efc640bca1403be796271708b7 |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee3cf1a59232dd49c0939c35ea68343032e83d1d7f5b76d193d1fe04e58f50b6 |
|
MD5 | e7100ccaa218b8b0b1c98a9c0786e979 |
|
BLAKE2b-256 | 5d11e380d2644c5b9302a5c0df655a8220e2dba94e2224167d9db885e4ad6508 |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96f0e10c8d0cdbf22ee928baf233f2ba95e0016ddd1cf607a771b3e9f4c16911 |
|
MD5 | 054ff648431c02da9e5a2e6f0867f698 |
|
BLAKE2b-256 | f21c8f5f7cc13e35b6b3669a2be32d3e9f7464602133119afd9031025e2aed10 |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87250bc7d3b93db5da218d15d77b94bbfed93c2e4f06a226428302bc411723f7 |
|
MD5 | b58dc4b0997f022592e332c2991e59fd |
|
BLAKE2b-256 | 514a5c360bed333e00ddbd9c2eb2c75a8da5d26064a3258982cd888b97fe7d32 |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3878a67d1e0e4de89f6e72e8f46f5206d14d87e4ed70af57d036b16094c4f43e |
|
MD5 | 54193ae0054a5d362086656daf87460a |
|
BLAKE2b-256 | d65675646e3cd5d74f1a224818f3d3f9cf6b53557ed557cab6c97292c250f32a |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 006bd34f1c38cc2a68f7ebe46b945abbffe8a8e1a923c14303ce3b4cdf74ae0c |
|
MD5 | 24d73d971d712a858c76bd9e5d0374f4 |
|
BLAKE2b-256 | 61eaab9a1990249000ff55573087bca9887098c8bb8dcaf71eadc64e511aec69 |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df98a7ada618e33d0a79843c7fdbda2bdfdf1cc6baa5ea24043efaa296c9899b |
|
MD5 | 71777c46b3ab8ec99764d41408852e89 |
|
BLAKE2b-256 | 385bef59926421114bf83a7deae71e1cfe0c597e278075aa1de004c95ca37ead |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b07f6f1435ee5d19a6d57416ce73ea6b92ef29f65bd5b167eddd19d8ee1e57a9 |
|
MD5 | 4d42a5fc971286a6dce31e58a63b3c5e |
|
BLAKE2b-256 | 11bdf144bfb090aa65371c05308cecf418e028406d29cac481bb02ace778e705 |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50016ecfdf39ae9dad85fb0836ada4d2236c0a9ebd368bc3387c4ddf74c0374d |
|
MD5 | b6ff6f38dbb4415c06b62ac95f5f79a4 |
|
BLAKE2b-256 | fcc049468d120a6a032cab96f72707a1b99a475b04bf30c702ddb6f2a6fcc9c2 |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 351345dbc0216c3800ad2816a76616e06015164bff4ae060c79e0408d8383033 |
|
MD5 | d8ead16087ea9af9504c0063b10ec21b |
|
BLAKE2b-256 | 01c6a18a8b77845b1be6e76d1d78d8e9a59adfb144937a92593699d945a2ef5b |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ceb91bee16535b74e342165a415979e74381a8836efd83d2a288e7470b86d00f |
|
MD5 | 86b1075f820ab757fa561cfe8d4bfae2 |
|
BLAKE2b-256 | c5674932e1b26af649cf649cd977f04b93c51442d80c4ce9dfc95a05d10272b0 |
Hashes for pyAgrum_nightly-1.16.0.dev202410051727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 156e0c07f59148b1605c6b8f413a08bf14d08b9d4f186e2f622aa3f004900055 |
|
MD5 | 9f0147d5b8c6c88530c8dbd37711a513 |
|
BLAKE2b-256 | a44d8c2eeee6f1805aa9c2a462b72a6bc5cc5bfe949bcf3cc7186a84cda69518 |