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,2023 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-1.11.0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 011559e8b78ed21ce7a93765030535f52bc3f1790643ed35f4f5f7a4bf8ce609 |
|
MD5 | 3098255125ada2f7b2260470fb063c4c |
|
BLAKE2b-256 | 6b435cc770baf2df29e1703e0851b9563dcc857e4ab4bb978a98a670a3849627 |
Hashes for pyAgrum-1.11.0-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e09d0b050392e5390b856edf68790e1f0bd0b51b39ed7b3a8849d00c37a8ff83 |
|
MD5 | fff707487b3827b7e0205e589686fc2a |
|
BLAKE2b-256 | 688a196ec21dd40c03b5f5421bc7153c9f65144260e88d76e53f464cd204b374 |
Hashes for pyAgrum-1.11.0-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45e8740a82eca7564d6ba3d1a621dc231de8c77a672d950ccf533aa077174d6b |
|
MD5 | e20b0dac833bd97fe7ebe0884b47777b |
|
BLAKE2b-256 | 79e1cc3601a69212430f7726d6b22d6c35ebc9f87da7c988878b0327dbfd5ef5 |
Hashes for pyAgrum-1.11.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d001edca596efb5448655f97d26c5a6d9520335f993d0f2bca5c5be065eb86f |
|
MD5 | 284bc83c95c38756395d5d0b86750c9e |
|
BLAKE2b-256 | 9f26e407679d7bb7f94df12790ad2a3224536d74b1243880a46d05949b196c7f |
Hashes for pyAgrum-1.11.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26a9dd3d5d7b9e8bbcb47e48b90eec642e157333d6e1e7ef9ce3179d70f48789 |
|
MD5 | a6ffd77daeb8810c2347c29a48aa073b |
|
BLAKE2b-256 | 904652b27b23c4f0a062da2b4e33f6f0da7b13e92df23842be4a69f2b14115ee |
Hashes for pyAgrum-1.11.0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e1d9eb57c7308b5d4dfa123cfd040d8e3a8d69168949cab3ab936e4723eab55 |
|
MD5 | a93a6da831a5478f8285df57db1ec817 |
|
BLAKE2b-256 | 2e469aa01a4f66982a7f4a6d98f51b840836dfb9272f013fca8e821d4ebc9ef0 |
Hashes for pyAgrum-1.11.0-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 781a669e15d4974b236b0ecd6555b53febb0f570fe65f8d501b9b85c51b8449f |
|
MD5 | 45af4c3453dd289867c4776cff9229e4 |
|
BLAKE2b-256 | 3e8303d47a9aa2cc199b3eb3b04e79eb38174ff92530a822fcd6cfe6dd2231f0 |
Hashes for pyAgrum-1.11.0-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2845f315f8eacb1153111d4b3a89d633781d24863a42087901248d68ce876ae0 |
|
MD5 | 1d1290a082e0a288f5f4d3fc96c792a3 |
|
BLAKE2b-256 | aa7272260a602b0dd3a98dbdde691ae8de4ff426f14a71ced035f1629b434e85 |
Hashes for pyAgrum-1.11.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36eb2f8829033ffea258e66180b2b9be45f1dd73058343b1934c95eb96b0b00a |
|
MD5 | 7d82405d8b0e37f988e827457cac8b23 |
|
BLAKE2b-256 | 658d74d710f37993954e81765de113af81f38fcba1c165c93e7f8ae46b31af98 |
Hashes for pyAgrum-1.11.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c6403be54c6457185f24d1de6c667841d23c3422a2c8254482113b6800541857 |
|
MD5 | 4427f4b981ddb0a580652303257954bc |
|
BLAKE2b-256 | 9942fe052bccd86f7c4a512a5f5a892019bf0f54ec16926191ad56cbece58840 |
Hashes for pyAgrum-1.11.0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | adca87f8299dd8d9510c31be33932c5fac9e95dfb9bbf9c88caf9c18e0de1e40 |
|
MD5 | 79f2c2b68c7f32413cd6abc136e7fdd9 |
|
BLAKE2b-256 | 98d003821e1c913bd3137faf23a5c5804e71c7f4b27994c410a1cdd2b3c42c0f |
Hashes for pyAgrum-1.11.0-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 193cc7831a13fd19176de1b845714daf84cd493e4e4f719d40cfe2042928b920 |
|
MD5 | 377662773897162062c639266693aef5 |
|
BLAKE2b-256 | 27de9e5325b27fc5688c77be344d05a3dd4d28f28a84d185978424baa1dd5d11 |
Hashes for pyAgrum-1.11.0-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c02f839fef401c0e8609b1efb699212c055574c5940031790690dd4696b769b |
|
MD5 | 2aa657c9c333a33f36984aacb2099ecf |
|
BLAKE2b-256 | 4d625baabeac2b94262097dc7c6ed53d100da979ba581fc5ab5ea05df098af8d |
Hashes for pyAgrum-1.11.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4830b9e1b7099be644c7aebce0ce3fd680fcb6a18d990d8f9486ab40a1ae9947 |
|
MD5 | 8393d0f00b532bac90f172282723ecc0 |
|
BLAKE2b-256 | 9d3b14d7003f3d94200bbecb82646ed6789736fa8cfb71a284f6a8437b238eca |
Hashes for pyAgrum-1.11.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa6de2c1b1d5d479a2d1395fc51c8dffd904c0df7bf84e990f4dc7eed76c3c42 |
|
MD5 | e921df96fe9d0a533e2471f27558a5fd |
|
BLAKE2b-256 | 4b663366eed90c0910c1083cd46e841a9b88792af391c8e80e53e6bf41e83a79 |
Hashes for pyAgrum-1.11.0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffaeccd8105dbcaeef4819d5866d7bc0e8f736773708beba3313b8b7e2356461 |
|
MD5 | 455e7970743655428ccc043d16624b6a |
|
BLAKE2b-256 | a2ec0a86f01f1c00bc20590b28751d393ac9a7ffe40f2d3663faef25012c9dd9 |
Hashes for pyAgrum-1.11.0-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46d25ed97ab5bad47ef8111970154da35b9ec961dcfb02e7f4b20f92d30c1891 |
|
MD5 | 5630c0233ee36d0762b0b71f060fe555 |
|
BLAKE2b-256 | 03b04425ab2573135a67e362713ebd17e76e12c2865c16f1dabb3dd1898cfae5 |
Hashes for pyAgrum-1.11.0-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b520aa026df5913c226368445dc5e6d2d9454ec8dba424a47a00e68343c0be0f |
|
MD5 | c4dbe649361c150155b4850b7eac670f |
|
BLAKE2b-256 | 6a34efbf3f9b03e026c9124b416764f51a835b50bd337d3c9e6ef04416db02ad |
Hashes for pyAgrum-1.11.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd28f00a47e47efa4831ec55226b03ce9a0514431f48a19a0bbe8ad85830b8b0 |
|
MD5 | 529acb23e20a7dac205d45c7689c11a9 |
|
BLAKE2b-256 | b126d6209eb6d0926f8f4a32202762923da0b58371aab6e6c82566809bcf637b |
Hashes for pyAgrum-1.11.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c99df54a3df6dbb52ab5a90889e6db93b20eab9e42ef28d57041933713ff5b02 |
|
MD5 | 4f52d9e97c5b609780b37deb295b4edc |
|
BLAKE2b-256 | a0f98ebaec319034bffd031780f2204927e59550c769457617e0b1c807623deb |
Hashes for pyAgrum-1.11.0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c728d4e39da025b10fe2395486c677fd49b1497c4c2fc9339b4893c569bd1582 |
|
MD5 | 925fb9f89d013a93e2cc3cb05a5c5d5d |
|
BLAKE2b-256 | 4cc60cb5b572cdbe98e117557f5c21cc4033374bc3a15f4402ca34ad805ae969 |
Hashes for pyAgrum-1.11.0-cp38-cp38-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90d8251ed5a5250cfe5bb765351577e71a6458f2ef6c896e32c60cc89b3f6d6c |
|
MD5 | 33da232d0267b0e1fef841c1fb79347d |
|
BLAKE2b-256 | b1474632880df643c7b2aa14d291cca67e8991500b5e2e38bfb24313e76aa13c |
Hashes for pyAgrum-1.11.0-cp38-cp38-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 31b46960ebb8414b60d9259892da529ffb954b56472b6b786e848885707fdd7a |
|
MD5 | 8396d9fe419d15984265f267b6f1cf0b |
|
BLAKE2b-256 | 78ea22eaa0572e05156d36af4023b5835f2c1baad4725fd581331bc39ef91058 |
Hashes for pyAgrum-1.11.0-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2248ad9f2971e863889bbdd39a1d3780fad310e514000c0dc090de6e2fe0fb99 |
|
MD5 | 7f03ae2be89e1333cfda4bd5c26f85c6 |
|
BLAKE2b-256 | 58520ae732750af284fa6919942aa6013692ebbea51606456a492b76a02eeb70 |
Hashes for pyAgrum-1.11.0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cdb65648513a78e53e2c56f803e248cea13d93d6e99d09a600ac93df0900add |
|
MD5 | 1181d85ace5bb75a894cc27d15401cca |
|
BLAKE2b-256 | a822d382f6162674afeba3015da682213459ef11ec8d55346e3b1c6ce74c0ac7 |