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.dev202410021727562243-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc9d0de846a397c207c9aa38e2384d5be466eb6ee2b464e94a29ce306554310a |
|
MD5 | 92514fefddd41146a27ac5009f9635bd |
|
BLAKE2b-256 | 10086d120d7ad24900b6248b1b5a3ccc8a690161e72d0bd11e541c7ca451d48a |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a78ca96e1b81b902d8f7481dcac625b3d971e3985df24b8414d4edcfa06380b1 |
|
MD5 | 93102a0f43261da78d599915f7150f0f |
|
BLAKE2b-256 | 1fcfe462b3283b02b340ad3db8ad5a32ac4809957d99d9b60863cad4703ea8af |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e04bc9ac623cebfde7200ee13d629def0367c7d95aaa127e4f91b609814a112f |
|
MD5 | 767073e6b9cf899f5cdd8d70b6d81b26 |
|
BLAKE2b-256 | 7063644804528235e65f445e287f84785098f26396b80d033d34e47b73406c51 |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 229987e08c9ae765eb18c0ad3f9808215f8a97c23f1d01ab680cd218fd52e929 |
|
MD5 | 7c8b1e4934615636e1df0270d8755b9f |
|
BLAKE2b-256 | 53d63a45c98ac43af366ee0b5d1af8ac7b6d143ff946a46145da184667639c4b |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b96a5af1bd11302f94fb04823be83f5751d0dc5594eb2608d8e70869f9807a78 |
|
MD5 | 474116babc92ed479f4b958225b8fa29 |
|
BLAKE2b-256 | 8f548ad4f1634238b6bb52cafccf684dd5ac04f5cc7e13e92d68ad4016812c0e |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28217abed22eea8be4b92022497391a5443bbcf6b6a79d6ff17b871fc2a77593 |
|
MD5 | bd4b62c0ac13500279cdf7209ae7530f |
|
BLAKE2b-256 | f0c544110dc51be2fc0503164d3b29c78d5a01fca0f7e7b10906fdc290f42944 |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 304e9baaee414408dd8533643501bcbb55e84aca7fabe56d43c7dad797b59fc8 |
|
MD5 | 6b211ec9ca3484b77e3fda72d6bc0724 |
|
BLAKE2b-256 | 78965258d7d478ad9d0863a023f4e6c39d3987ab0b4e1d4d067d73ffe8777dcc |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3405374aa9c8533047b09be158ec13e61cffa03025e4433ec21edd01ddf5f9f2 |
|
MD5 | 9b19dcacb162b9fb9e9a334fa2e8e534 |
|
BLAKE2b-256 | d6e5d072bdb60a30cbbd9f4db1dd2a3e07f866c13954c97c1abeb89621a7c17c |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b2ed0766e0b3164920141b0363488d27a056a5ea292d4bb17f08f2ee39c1a22 |
|
MD5 | f27b6e226688d5901f84d573053d1732 |
|
BLAKE2b-256 | 1489b15329d3a88539ac1d6e877eac7469a4bc112e9f53e568adb60f1b1a6594 |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb0f0dddf76c43358b156f6177d0b29b2bce9e6f5d38486e817ea66af54ec1bb |
|
MD5 | 2263cdea3311664119f574b44e5bcd91 |
|
BLAKE2b-256 | f1df2bcb069d57185d124120c14586014f68198c173cb4bff65e4fc3eed20470 |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6fb98b23585e4e64836d19cb4886e39381b803c2216d2d983c04341ef4603034 |
|
MD5 | 85c919ee3c28c9ee44c4f7aae9f45bf3 |
|
BLAKE2b-256 | bf56d75f3b301b1a250683127cbf15e0d82691082c91887007256e5b703491ff |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75bac126331f3fc3d252e0f8aac86ae21fe680010fdd131c714321c5021c2dfa |
|
MD5 | cf163f2f221d28ce274d582e04aa3ae7 |
|
BLAKE2b-256 | 8cdf2a04388b1750749ffea29918fb67cd5ec67320edd02e99fb71ae93ed0bfe |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f740af2ec275e458dd2a4232b4c364bd02f5323b0116ce47ec52e915bb995bb7 |
|
MD5 | 7791ef6d84e30b992e96d534fbd5ac18 |
|
BLAKE2b-256 | 60cde2ff573b9adc048e0a893f4eeb09c77a7f5323a7e0dc7a4986e1d5d789d0 |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85703cd019d7b50f3179e00d146be32a6f422aef3df22c16a7e30a3276be281d |
|
MD5 | b2cae762df121f21f1bb409ba1112260 |
|
BLAKE2b-256 | c605ade80610bab4e3ff8b729b35bcf71ca9f99a10ba10be329422a099117c70 |
Hashes for pyAgrum_nightly-1.16.0.dev202410021727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 389f9bf37a797cf5dd0a4e118ce9d1dfdc6a9b6fad45ddd4cb34ec9c41472fc7 |
|
MD5 | 5b2fbaab54894ea1384810152c419d23 |
|
BLAKE2b-256 | e101f0012645e9bc87bd83c92e509a56848098fe1e5b94529b3feebbd1b91970 |