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.dev202409011723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e849c44c5ef35e94c1ec7f7225ec93f8a0a11621e53c57053ac51ed0573db376 |
|
MD5 | c5390d70e21590704813e1a56c785237 |
|
BLAKE2b-256 | 654bb5f8e88212c5cc20181297226c2c1b1a06b2d112df81c0549e3a42b62305 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94d04a374726b22b7da1b2d7b7ba367362f590c05a0fe151915890db83683799 |
|
MD5 | d824623b04894a1336079e1290d167f8 |
|
BLAKE2b-256 | c22278521aa65186edb768b7cc5f22bb66d5d7f6d1d0c4822620dc6c2ec78b38 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3fc71c75a1ce1abf0d087cba33087ef9d4ba205dd36f5e7102fa45974a783fa6 |
|
MD5 | 9bfb301f0796d4c6be21d2cefbef279a |
|
BLAKE2b-256 | 33494107719737ca202b42c808d97112d20df492bdd7e40507a9f2e8b08dc0b1 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 690b8171609d47bd5ebdb6aee3a5b836e57c38d0ac8fbeba47c7410f5f82f98e |
|
MD5 | 9775b5a7ac1c017e0b6780bdf546517b |
|
BLAKE2b-256 | 1ca85d8293fa62d773f5ebaf5076b30e541e8dfc27b684b7081b6189ad3af950 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60da2e39ccc8119e59f24aeea8385b1b97ecb658c91e6da671fdf15516c1fb3d |
|
MD5 | cc21c2e1ed08c2d5f108ce8268afe5bb |
|
BLAKE2b-256 | f028c1420427802db283e9da5df2a4a751b2963920457aa2c210d0c6443b3846 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53ce62a41afef0ea32e79e13084f1fc8bbc2bb9706e778cd1352a3b9120bf3ab |
|
MD5 | 898f995d866dd787458409d9cbeba7b1 |
|
BLAKE2b-256 | ac1fdaf362b2fcda3878d3a05211891636f3d52b341aa8b0250fbde11de98d34 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56a9ba88b9f250e3e03e65378c5f9df7bec82942bdcd1571e74afb0c000bdd7d |
|
MD5 | bf0b562e859d272f9821ab26b94723b5 |
|
BLAKE2b-256 | 12284d646a9f9f3d5048cb7d76dcb5d45470a9adb8fd315d4c50cd9bf036b1c8 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 305700b4550ab5caa64d3be8f73378286f400b00cd3c203f355a94f6203088c7 |
|
MD5 | 3ea446d29d54ff5b31813b972e24fdf5 |
|
BLAKE2b-256 | e57ff5ea62b2f9b8ef3b9c27e284415d7b4832a8fdd65ce4b7e491c6c93d2b5d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e874e5b99612b540733be089277113fcc45e20e13736a26ddf9718b5d6b9b4f |
|
MD5 | e01d13936d9eb00c9a350fff464d6f09 |
|
BLAKE2b-256 | 82af0bdd421194dc2475fa68bec5d0d5683eaefc15903ea31135df1804b2c155 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dc466418eecaf8835ccf5ba4403809f9cc3bc4b35593b467666cb35a6033a73 |
|
MD5 | cddc913fbb4b187aa5c5260325594c6c |
|
BLAKE2b-256 | b360970e729e12f0d7ad87fda5a0ec940474b55274c83bf7f37c9044ef3f3174 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 336774223fee6dcf50615c09c93af2efae7574d2e55328d49628d9a2c5a337d5 |
|
MD5 | 0b821c8353927c70e7c97e2c85a522b5 |
|
BLAKE2b-256 | ec2691ab086f5c124ec4d0b056eafaaa04c5c4927fb41a1ab26fc310f4aee1c9 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b106285d174e80e939671feea682bf9ff1f174ac9710231e4848e971430379b |
|
MD5 | 1883c4104d28f988fdbacd59e0b36b21 |
|
BLAKE2b-256 | 43f47e8a90e2cc83e9e78e0d1723bc81f8cf0579f08d025c5b0535bc01ce9c32 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20a089de11ef87c54bb405b6dd6fc1d18e53134f623d1b5e6c5554510d0f3679 |
|
MD5 | cab808c1a0ac055d2155d0bcdb2262a4 |
|
BLAKE2b-256 | ed675ee880061ab83dcd09485944085130f859879f037c37abcc4e95f54f0871 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 040ad2d633c8b5dcd73e4168130dbac0bba7fe0dd56775edc77bfb37a09a88c5 |
|
MD5 | b90c688a3d4523a69bc30e0798cb3599 |
|
BLAKE2b-256 | 3be7329ec873a7f98af09a84715ac62cdd101abd4770a74f21a5ab34a5cdd8ed |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fe54485e6da3347610c8f774dca2bccb822458570735a41890195852c06e8e7c |
|
MD5 | 9025cf45bea85c1afbc4ed733feaecfe |
|
BLAKE2b-256 | 5e982163b1627e7df1317359c9c84cc5a99934602a90994a79916df3fe6e47ce |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c7c92b689f0b1810802d52244331d20e409bae8033dba88a59fd9b0ea48584a |
|
MD5 | 69165f92459cb944707e24fdacf84180 |
|
BLAKE2b-256 | a012745febe8c7a13127d72c980a98a730d0dbbe941f9fcb388f1715ae944213 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5063bbec1ef5e093097b2139cdf7c3e35360dc940c39e7655c54b0b2e5c9cee3 |
|
MD5 | 8832633904a5d3309920c2ff7986a5b0 |
|
BLAKE2b-256 | 2ad0816637e02bdd13b09671fb59a5ab900b2fbb06f09396f01efc58dcd4c539 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af41c92af1f9ea9b15319fbd1c7081aceae14b650f85f7948aa77fbd22bfab2c |
|
MD5 | 73ff1e4943a4a3f37f57fbcd56982b2a |
|
BLAKE2b-256 | 62b29dc24111886233fb13d7433bc6375ba7359fffda73310011b3fc75b577e1 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb54816edd832cdb8f5585da4f9da498f5cc93e9a083c24e37392a4d2b18e1d6 |
|
MD5 | af67c4e9c567fc65b9b19b11f4978045 |
|
BLAKE2b-256 | fc87ac644ef8e9759063f79c9616f6ee55feed1219682a9c203b77fe101a57a7 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409011723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26c9ee4448abc14bf02d0ea22ce459d91f6e50b0e2504789063f89aa315d9100 |
|
MD5 | c18fffc1befbceb854f9efa3cfaefaba |
|
BLAKE2b-256 | 799d76df9cb71ca31c1174f20d96bfd5ab04ccc0a4697e8ad1e855593dfed82e |