Skip to main content

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.

Authors

  • Pierre-Henri Wuillemin

  • Christophe Gonzales

Maintainers

  • Lionel Torti

  • Gaspard Ducamp

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp312-cp312-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.12 Windows x86-64

pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp311-cp311-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.11 Windows x86-64

pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp310-cp310-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.10 Windows x86-64

pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.9 Windows x86-64

pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2336073a16a77127546b916738d8a47433df9b7de40dfd831e79de2d36864784
MD5 b707c1360bd4c4f518fc1c746a04de4b
BLAKE2b-256 d9ec1324a47d01eece9e074d24111a96fdd7c22ebd46ede633e205f962de2b85

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4902728f696dfd11674c811d11190cd6f31b7c717d4ab94ee31831327ff78443
MD5 a9f91e61bd4f57db7a598a65fcc85609
BLAKE2b-256 42408515f9fd85cb960490aab3e133e47abad101db519de76d53b1b1790f7009

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp312-cp312-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 e78523920a732a8caae69ecf9965c45287761df5bf232a348f81bb505b7f28e2
MD5 f05b28f554f980bea3d949bf81f10642
BLAKE2b-256 fe32db6b52944eb1626cde3cc4cb1558fd8f6b0c14de115bf92afb03e7d20fa5

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26d61cab286658948ec689d9c0676853d4530d60fec9c0fa28fc7ab210c56b41
MD5 1238ea346f56cb0a44da55b6d0f21cf6
BLAKE2b-256 156b3d0c99e1fa503495922cc0fb9607207a98dffff5a576fa67b20ffb8dcd33

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e7020a3627131f5e46d631e711a60035058c1ad485017e9ee60a66428d2cd51d
MD5 aed034aaa9c2f57ce7ffbbdbd1939586
BLAKE2b-256 67296bb994da478500421c2233a4cc4270e9dad334934a66a92eeb8647ab09ff

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 48923f7c1a8d63e34d8183eefc2a5907e41a5914565e0022e34687c4d54e8eac
MD5 528cd8824693f1919f8d1ed4922567d7
BLAKE2b-256 b2914118475b09a870ca30fb3040cd211263f15a300d077e209714bba0f246a3

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 079331ec5cddbf767f2c813929d8887a1d69035c814d1709294452b4e9fc4339
MD5 014829190f6f584807c728b60654308b
BLAKE2b-256 f2cfaa22ceb7534af1a3291a3bcd7a18e0af081d889d8df1992c74f72a1f6a69

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp311-cp311-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 449a67158d728315f2530feab80c54aa48ede4c6acd5740ae243b3f7840b8005
MD5 d4d15cc2eda3d470d54678930ec2e233
BLAKE2b-256 f850f2386a5f5a1ee71858eeb29dc5a0de0358ff32e95762fa122d9052084c2b

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 73b8daa8de8818ed436bb4ffca11aba337144dc36ba7366caa997d1cd19e6889
MD5 01725beb2b2341be1821695b181ec218
BLAKE2b-256 f88c813d382b0ecc1800f875c343816f4340d8c095e05086c719efce49d22235

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 89da8fa671537bece2b2e6d9c8883ae2e72eea2a714fde112fb464ad85497e93
MD5 9c9a157ddcfa941c17fdf707f0289f5b
BLAKE2b-256 2c86513622656c9e6f635fcac55cc9460bcba4c97dad12db3b973c855880eaea

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5577af4c4766d262ddfd18559682904a69413c7ccbaed9462778a0aa273cf7aa
MD5 708b45db675b7f141976354a0a70cf5e
BLAKE2b-256 e92faccad0f94a2a8e4032601d087209dd4ac0d9fbc0a1291582862927b0c446

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e404722c90e4ceb1ad0c5fae2f581ba1af4673a8893dc852be8f7471f85eeb0a
MD5 54b0281f8d6695e9fa318b267d77c62d
BLAKE2b-256 c2926136b8afdfac0d744bc4a815ad039faec45f294fc674af0ac6a208dba046

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp310-cp310-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9ea56d2f3ef94034102db20354913bb8c9a3d212b1f2b2209f1f0cd3693f7322
MD5 d3e5147a5509abb3b5e4ffc1fa053a39
BLAKE2b-256 50c7f6d1b06d2b7a32e929fd21dd4171818eacbd65c3706dd528da8080d81796

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4be2f54d25e1f9327b47b855894b92a5b08af5e766bf76ea2baf480479dd0a33
MD5 20aae66bb40741f0c82d98c5807fbefd
BLAKE2b-256 19a4ec68e7bedb5c37a8cb2c99bffe0df71abff82d57b51b1b904d171bee613f

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 32157ae6ec46d094475172f1d7eb1121bd1e5ca49bae9041de6d96599290f12e
MD5 040e1242c4da87aa29495409855a2e65
BLAKE2b-256 aca9955397c503bb53172e3f75c33e893dccf9f4268134a19e3ab65b76744ede

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 8453deb1d30a4152af70e1caba9827cc6ecb23e90e007dd13011efbe71652547
MD5 03b6c504fb1170719386bcc6a12db21f
BLAKE2b-256 465e228d682766b5acf525deeeb7c185c1005e89e2c3051201f6fcf4395577e6

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8e4f42ffb7ea895ce67686d89492a3551f1397ba6ea19f6e98991b4160ac0554
MD5 b3bf8077cd606470983edcea1c6bce8a
BLAKE2b-256 eee716b59506a78d3066b5359aa713ad393ef602fecb71980b71a3d613894dac

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 daf2c543586f22fe4557d3296b3091f15a5c801c4bf1f152c70f3b403f1b860a
MD5 cf273617b608130383c663d90638e345
BLAKE2b-256 8423cc4532ccfd3208128eff0c4fa173ded3194a453476db41b1b7274c0e45cd

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 38fc996c60b5b5e92563c46f3045d358e5abf79b3e8f5bd76b7b2e348970ebc1
MD5 80af4abc481dcec332495b6baf69853a
BLAKE2b-256 b1ae2318438775c46dde138fc762f1d8ce191fb63ad9e72894e5280c5a9fac1b

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407041719384100-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5159d97b1d6df759322272e74b625d2293abfd84b8802c74794ebfb988b62369
MD5 7c2e699655197a3c903bee46e262e7a3
BLAKE2b-256 06ea6165750c211a59d819694a2807e594e712050f77d97adb62bbe455e4234b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page