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.dev202408051721169663-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccbc086ea30d0c90c7e0ad52347607b03d28fa19c2c93f7254ad98ae59a3864c |
|
MD5 | 46fa3a14a8da16b8314e9694efaf8995 |
|
BLAKE2b-256 | fbbe47734c607261ccab5e68633da2a056d2bc2f4df4c6f98f4e05dfd6801520 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40b2063065d6f4391967c8287b0bfb204ae86a85bbea8c483cd0f4fdba95df89 |
|
MD5 | 9f91034ac67c05c1a1437982020443c4 |
|
BLAKE2b-256 | 26928b5f6ea60dc7030546ae1b410324df01411c6bd6a6069abea68686b1eeeb |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | feb5347257800f44fa847e6a43738a6dec2dd51e0dfcc37c2b5c32977ab05566 |
|
MD5 | 0326b3b8ebf48571d44ff553cc96e7e5 |
|
BLAKE2b-256 | 12a4a6ae69b5b79e26bdf4445606d217b91943cd049081edb6aa09debed8e0bb |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48613d7afe5339d5c78000ef0db0f735af624eb591f36c1c81dc8b2613f2f6ed |
|
MD5 | 53b1893e5fc5520a7b49db7b84ba8957 |
|
BLAKE2b-256 | aef48e212c57a6f7ddd4b7cd543125432d0ae623844214ef252f5a4562fb1372 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f298745e02ba58b6d59d399d1fd0ac229a645b3301891f27ce6b1e198523228 |
|
MD5 | 7b985a4cd7672786c044b6f76965872d |
|
BLAKE2b-256 | ef826792f6642707840aae5bf243852245e1610a9dcecfbdcf0e45e6b40eafed |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d84fe5cf3bd3a0b3e38343b79d58994ee8dc1166e7dbd4516e9af3dc4afaf55e |
|
MD5 | a249a896aa31a77a1cc55bb72e650b74 |
|
BLAKE2b-256 | 48c93b89a74edf8e7e5fe0b71d4c053b7b87c4f5073ece6381bee2a9ea29f2d5 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 629bbee02f964de7d0cc56b6eeced221a36d1e05166ffb436e1be50c630b9bc4 |
|
MD5 | a1a0df64cd91dd7bb210ac89a1154ed8 |
|
BLAKE2b-256 | 9c60bb15a8a000411577cdde87828fcc7a0cdbaa7f4f03bb23fad2f5e848c87b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dc4e642910ccb8d95e336ea041f2135e986ff94d3cbb81c494fc293f57ef1eed |
|
MD5 | 4984ee9921f8511bf21a197680bca77a |
|
BLAKE2b-256 | 88b5576bdd91b29f17ba33c7aabf85b476f7181c57d8fdd0a2db0f36933d3850 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50d3f173b90e46acfb00a0e59682417bce58b87487a4c82b7dfa9242188a6efb |
|
MD5 | 84744c99c25c7c4e797256294d450269 |
|
BLAKE2b-256 | de69fba3b2980a4a47bae2fd00de906769adf771c1ba143cbbff90d0e025e7df |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36a465fdd1285da1918fd23d75b1649511325412af681e6fb8e20983479961ca |
|
MD5 | 83451750168ae3ab99b9976eb07c2dfe |
|
BLAKE2b-256 | 8d4a602512812df29b8272507430f44095efb4501b7fed0b8ed453fba025b4b6 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ac5e297e7fc67519fb1da697f87edc5a864d18aa1e485e6af5defdd54971879 |
|
MD5 | 26ad56ba091977d17e65db3a51d753a7 |
|
BLAKE2b-256 | 0d8f883ffaba94206e92fb6b1dc73120052551ca4169d7e6bac35ba605072bf7 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b53417efe3957481068fe15c0ddf6ca5f35526b89dc103aaf627dc8a307af720 |
|
MD5 | 2350b6e584e179039eb671cb96eded57 |
|
BLAKE2b-256 | 6169ebb76de772cc44888114a57ec1c5a60e0e740341e12664cd1255c0df3e7b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e957c03b5e73da9c0f78fced1e15a12b61604a95a5fbe1ed0e800b2df62432a8 |
|
MD5 | b2925bf9bde3052d6b1506581b56f9cb |
|
BLAKE2b-256 | f06e074f0e6080047f0f77be6e32edef94b4087c1ecdfd6773266f73233ed7c1 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0085428176885867f4815fed149458a2b17c310b24ac14c7622730f60a77495a |
|
MD5 | 89f8ea2cca208fe8420b8121b7a76a0f |
|
BLAKE2b-256 | 2344e7f94c2df11cdf7a99c5a7f7c43ddf99d2889d879e4ad267f34959a489e5 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c7f54ea0a188babbabdf1ea4a42dc1161f47a1e78f89a535443a73978fbbb4e |
|
MD5 | 42595469ad35b14072e3ff8d54d54d89 |
|
BLAKE2b-256 | 68e205935517a1cda07f1a8ef08c1581481a4b6f160863d558be185d2a4c1aa1 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86869586d810107a9af8f2cbcdd09654f49c0c8e7dd655efe8ea9d5c5ed48843 |
|
MD5 | f2b42352a815576c154e224aaecaffa8 |
|
BLAKE2b-256 | 7c181fd5c9f8bf0441db5dbfde26d41fa47cb2ff84046daafecb0072674b4fea |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e97daa2f8e707dbb7b79eb5bcb72fd9cc212ef11f899b5aae5e20d08a993b3c |
|
MD5 | 9641e80a1e87e78a0e4e5ee1ad1edaae |
|
BLAKE2b-256 | 7b1fc6e3157269b7d9d70cd0bdc303ef4aeb56af823add69e2f7b84b535a321b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e07b80f9fa1a698d886a3e76d58ea5929524081aa26cab84622e3e7ea43629df |
|
MD5 | 94b009f26a280acc8b9cbd04ef245879 |
|
BLAKE2b-256 | 32b7e08bdbdc3b51b35af3650414ec3fbdecced3a0e708a7b6f3f97a5dc63fc0 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29a35b999123666273e7175cc304e45e53dac829d1f384cdcafcf82aeded474e |
|
MD5 | 48e98a504b40b9a4c536200a3a966587 |
|
BLAKE2b-256 | 20d715b1878ae95557aa85c76ac7bb99fbce270c4f912885d394b834d8c02303 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408051721169663-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5d4d1e267733d9728894c2f4a1a41c5e8fc9ea910c263310341548c86bf8921 |
|
MD5 | c054ce21157462177efd757d06d5fd32 |
|
BLAKE2b-256 | 04618ec1c1763625782a1709b6eb0ac113ebe55ac1b0730a3170c1ad4628610b |