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.dev202407051719384100-cp312-cp312-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.12 Windows x86-64

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.9 Windows x86-64

pyAgrum_nightly-1.14.1.9.dev202407051719384100-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.dev202407051719384100-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ff73f321238d71356b08c093590b9c745195bdbac314d41171e8786b6a984e0e
MD5 0fb6b79727aa188a4c4ce1197bd1f961
BLAKE2b-256 9c07976f2143d8d49aac7f152f16e1178aa49b82d00be1098462fc17f682d5a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 11145b6403c6e5eb7ac1ffbe3ccdb294cf16851be37082af016c233a1fb62be8
MD5 efb55239bbf2c1db927d7475e66e0bca
BLAKE2b-256 8e39d1e6f45fa4b4793af806e20760c652bd921fc8310a64275f86fa9c84c1be

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2785e95ffbda13cedbc31457e7b6171c4725e21c219eb1f7a18a481299885d86
MD5 a892e61a1de1d80fc98b3d6aa969d45d
BLAKE2b-256 67baf5a208661770a6d221e60b6d7dd9cc3f3809c5fea91ead7054d84b0bd904

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c96ece086d48b651dad20b013df10658b0258fcb88194d0d54ef9eb546f94ae
MD5 e5a10fc8e79fe8fb003468e8afc1d146
BLAKE2b-256 90ad7882116beb3dcf0e0846877fab787331fdf00b40b9d8b3456e3d29bd4b53

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 74916039c758195a4710aa5dc402f3d8a98daa9b1d9594e3e413fc05fed20db8
MD5 a9da1b85319f84fa2e2ab6e31e5a4256
BLAKE2b-256 bde2aae43b7ed82ff7eddb92aa065622bd057386f0eb92902b86cfef3562efde

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3f22ed6b0c2c827e9b5a86560c4ef72dc76f2730fb29dfdbeed050f4a035f7cc
MD5 4be66df1206f2d41a4114f10c54a9a1b
BLAKE2b-256 9096621e167710ede438b9d2b5edb13b592026f9e71aa7b8e27fa0b6328f8566

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c158050c0791a6938b49878556121efb624115cf365f4e4d06684624a040bebd
MD5 0f9bf93b107d3e5074bd8b3888936b3c
BLAKE2b-256 9c255ccb87fb6c5669bc3e4bc86440c893429ebca93f04d10f9f6e44a2699dc2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6fe650a363f152ad24d165a1172c6884b20bdc3b8fd1686017decb1c3f13a62a
MD5 5cd9cc9ecfa13722c75623e24a122b11
BLAKE2b-256 29f356961b7a26a84145840ff85e8a114f0a15f567a21c0e81ee57c87c552e8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c597be07932a7da87be637dc02f1221bbc8fa6104263382719c03d15f0f2c029
MD5 cb4e3c7a6c232b3b633ffe0b5a84470f
BLAKE2b-256 ae66efad8b36bd908a58dd56d61f38d16ef1f7d651501e23a22d7194a35ca7d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9ed681c8a309118295cad8a5c107a523ca58015fff825e209267e818e84f430c
MD5 27a38efd4f228a92790a29e34396922b
BLAKE2b-256 ab49097a7f86fb36b2fdad1e3bde5a2825dc5f47fa5d98a733b601264f48787b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 127c1a4eaf0f7efd33f25953e9c47b6e0cb6c3a3df3c291b50abff31ece545ca
MD5 3a1bae3b78a6036482e4db5aa001acd1
BLAKE2b-256 3478508d372451a1e51f3d990c690ebcb3817f089a68902270bea71bba3903c0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 29baa42c8d8cbaa8dc7c4602036468769fe9af27877a71be731aebe81afc6410
MD5 4d3e8096bfe850f10377609c2e4f03d5
BLAKE2b-256 0a555caf2241638508b50f070992ce1a1ba8945a846ba4b07ab4c9943fb464d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8e80dd9bce09182155993663152ae10f0f69a6fa62225e4f176ad9337dcde6f1
MD5 6190b229bef3b6e5cf0d453bbd3ff5d0
BLAKE2b-256 f9a66e54697bbcdd7f1f271dc8731022926c7a6b8feef0ebdc02ba0ace7a9a7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a16079f6fdf7fd6029903e7bc70d3d777c20238b3cb09156a7db34c8567d0bbf
MD5 7a3bfbc0cccc4ffb137d7568aeff00c3
BLAKE2b-256 e2917ed5bdae74c90c6f52b5d81789268e1f831cca6db9f581df2fa64969cb1a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0042b332e1b9e98d45fe965e34bf6478b8172c45ce9506b7526b9ecc9734aceb
MD5 1fe270c8184a0c09171233aa6356105f
BLAKE2b-256 6a2241931a0d90737205809a90b927d2454db35541b29a9e531adb62d4554d32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b83e4df962ff9816676abc07a37985194d69508cd24cec0502d24c454555784d
MD5 9b1aec8c85e10edae781ef725cd0d310
BLAKE2b-256 e526918a274e2d44337adab075e7b3a74b97d6750dc856dda730d77844d5f52a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e340a1dc392e9dde3b672854d29cb4812fed9e3398e8f58d1f3c6b860d1c8bc4
MD5 eb1ebda0cac0b18b7784e955bc44ff6c
BLAKE2b-256 5577e6865c1f636990d0c4e491c6811e678ef933e979e0f4571d9f9aa917e2e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp39-cp39-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5dcfd0ded599173e45bfde93b091b5c93fe59ea1c104f3fe1655b8ed35beb472
MD5 2c88d26f5068409a0727d01c648f0fdf
BLAKE2b-256 6101d5ef670f1683e10eac8cb1778648bbb5520954282f395cca4c3c73832b12

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 70d3e8c363d4c6ccb3b050d4f4b6521b5e041f9e8850fb38bc11b86d12270695
MD5 89628b087c54483866b168a9fae7f95e
BLAKE2b-256 b34f26c1928b9f5010e68a262065c817c246043b12f7125ba6a1a1cd740e7ea3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407051719384100-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b8e51b2ecd76d3a8cb69140535e2bc9d5edb7fc2ccd031d02da2c6acd70c1472
MD5 49733523cff5b9c6d22b272384747cee
BLAKE2b-256 7f4f91034f04b0337a05346221700146c551938117b4f8c07bb8256b00c7c1a8

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