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.0.9.dev202408131721169663-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2d0f7cee2552f31b128d730d7429cfbc5375a4850c575d52467b540eb12505a |
|
MD5 | bc7b7795147f8a97519d4843af02dca3 |
|
BLAKE2b-256 | 29488b578d31c6d29d16e89799494372ba497b24f18124973865987dcd727685 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9191aea6efc92329d2457d22daec8778b1753f4cac51f008cfc6b36f3f7193c3 |
|
MD5 | 3c8c8315678b1aa5ce91b519efa2f6dd |
|
BLAKE2b-256 | 315a31e7d000544d237db14f113078825acd98d668d9e127bfa31bc9b8d74214 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed7d0a1ebe68465db7c0cc33f62847341d991f7536e1e2a7bc9022d382e69403 |
|
MD5 | 89e8cf407c9765424c1db10ffba89ab6 |
|
BLAKE2b-256 | 6ce9967b6111b226b126bc036e907af3691c98326657af962a8cd3239bbe795b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdcd492df9ea71b1645b81dbf22dda9e2307b6c601be09da5526f7d8ff413c0e |
|
MD5 | 8c6c79ed1e67129ab8e304de4fa75546 |
|
BLAKE2b-256 | fcff26ebf430372ee6a6ebe9f167ea4e54a6840aa84b9dafa97c46e280587b80 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f3a5cb0e9312257a387128d53ee449bcfa1adba844f7649313df7e80cbc1dc8 |
|
MD5 | 2f1f73e27609ce0636ca8b320b278edb |
|
BLAKE2b-256 | 78ddb5c8aedc8b92f65d62a855ef3eccfc45f297642a4cb2bdfa35e6c9defd81 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3761be8072531ff1f584c385226f382cb07c020f9f6f0e70c05383c383980b7 |
|
MD5 | 5e6e3633acd0381327bae8937d3af239 |
|
BLAKE2b-256 | 7fdbf0b717dacd4b669b187cf0c4331a2f650ebce446762843275acddddc4350 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15632005441ad849905d376e5e14b960757e341ed52eaaa398e9728715d68d56 |
|
MD5 | 3ed473394148a8998144ec955e581ad4 |
|
BLAKE2b-256 | 3f0e91c38d0a9853de077faafdaf464de66ba94428a61f659a7d092ecc4f3913 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f2c0ea2b69ddc9726d83c2646e2245a8769edd7dd5179229468088fe2a25d17 |
|
MD5 | 2a9733b9514f4a81e6acdd53f7c3b9ff |
|
BLAKE2b-256 | 1fa52c82db1f19abb67b9df1e5d19da128137ada13374ded8ce7b2dba7ff82a0 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bd07201cf4dcd8e7e8afd4184a8e9e2631523ec05743bec19974a5e1d99984d0 |
|
MD5 | 5bdb10c9194df5e3a463b8efa32dfc0b |
|
BLAKE2b-256 | b34ec685f1c85075c80af3980ee1b73ffbe15e3a5352507875a57b144695a6e2 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a13ba4a712a3b57ca0b72149c4e73bbe7b6c42d505355ba9eb10bcf730580c3e |
|
MD5 | bdbc315579455e787ab8918decdfe824 |
|
BLAKE2b-256 | d0e4124f2b65256a1befbbefa5462bc0bae448818bd779a7acce8f4af795b88a |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2984eca6589032ab5c4ac45cec945eda0058850676eda8f3418c3f0e28d7d2af |
|
MD5 | 9a6500e43f68d9b0200e831fc05e4eac |
|
BLAKE2b-256 | 366d4c37910ad2d2bafb3c7f719f0483038ac9dc5974cb7e4cb957ce887c6361 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1030515b85334b8797d6bd542ea187fa36492568e3881c4588a30096bcb34be |
|
MD5 | 74fda6add2afb48bcf653bed5fd64e34 |
|
BLAKE2b-256 | 8f17b52b17fb9c5bb317b466c7cf56ac6a915b9c7cfa1fc5146d2d87b2394a83 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67e778015ad1ef83d082584b269a1884c095afff0adb4684976276481e380d9a |
|
MD5 | 5fc567cee0da64a32c6dcd2499fdc234 |
|
BLAKE2b-256 | a00659ddf78424e76b675c07788528d054e1fede41404cf5312c6a0b5e1d56e1 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e35c3f61e97d29339f993217bc155a8e03d8f1f0db9aad78e0adb04468932c41 |
|
MD5 | e3f2dc7ffe48944a526ad03246884f66 |
|
BLAKE2b-256 | eea78a1d0f3cd6f25c7a244a21f9ccb6fd93d4004f07a92d22a0f6fbe4354a1e |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ba38029b2c597e69211b919e941650d85cb9416f19af7ad24d6ac652e8e1967 |
|
MD5 | 170c15264fa9ab6fe289a52193c5673e |
|
BLAKE2b-256 | 241060526785bf3de0c9de5469ece4cfb1448ec33610ef89e420d50b0c5889b6 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b8902471fbb888cf8d7f63c67d36ce6c0ad99af7b3360a0aab25ac9c3d3f8d3f |
|
MD5 | f98572d18534e9ad584fa439ae328a2f |
|
BLAKE2b-256 | d8013c7324d7b991f8208ae1627b6e8c4ae6be7be5620dcaefaf2ec8e15604a7 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5d155df2fb096fab1795cc0be815c2d6b33a19071e36851ef7a9ee9fceb1c18 |
|
MD5 | f067370d117296b78cd33df38a9dfcc2 |
|
BLAKE2b-256 | 51dcad4a25330523760d81564303b8952a83587bd4eaac8a58864911b23e30f9 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b89bef3f5a88b38dc0d9333e82ad9d502ad8b947a8b60a9a0f5592cc241b1e9 |
|
MD5 | 8505626be885831f3697500108eb012a |
|
BLAKE2b-256 | 87feb5d00d3b3d33b0282b39c7a16cd458862155a231e4a7e058d0f3eddc51ee |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7a728f338cf6604b3b837f9b86cf11b949ea005455c628088cc113eca31c561b |
|
MD5 | 71cd533f0e73655d4e721104a927ef38 |
|
BLAKE2b-256 | 5f6a66246392ddc7f0f919f8a2d30f7bd09f35470d3f120359d35bf667f1fd45 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408131721169663-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d91f72c36d663d00c9c66eb6fb27a618348b07336b22df380b74ab42092e603e |
|
MD5 | 3864e0be74fe7e45a3e8adeed92bd859 |
|
BLAKE2b-256 | 60d85dcdfbe8e059a25591c001b6c44ce3c7645baf1b468ff0c5274e75dde6cc |