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

If you're not sure about the file name format, learn more about wheel file names.

pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.12Windows x86-64

pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.11Windows x86-64

pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.10Windows x86-64

pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8aa87c8c6a37e60a61244e544c658e7b8b4ef7734c8b14a9dd6b8c974e322aa0
MD5 cb89c66eda93df0d82664d72a2c3b339
BLAKE2b-256 64000da1563cb63e16aa0db5c3a322973a3a6b32ca17d910f22edb42173a059c

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d382a95d91d40920bf060642802447386c6227325af79b978b4d2d2a4116b270
MD5 4cac3fcbc04e511576b57fc98df596b4
BLAKE2b-256 f9f14a487d5f50143e0f22d4949f751b2c39787ca6289c368172f9bf1a852850

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fda75858af005f20e96114295fe1ea9e31520a6ab0d6b0813a8aec6479746b2e
MD5 7941f76dd59da1adbc695a0541849a1b
BLAKE2b-256 768a6418911f74d404a3a8df56dcbffafe8498ef7be8ebb407e5a7d70a58e5de

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c9142248734e1690bd5895384394076e1fc369ffb3bf5ecc7bea7cdc99bb2921
MD5 5aa532dd6d9ba183ff23a9469d1b41c9
BLAKE2b-256 f818142eb5af427184fc189002d1f33a062ffb81a5e8d144ead4007ea5ec49ff

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 293cc54982ba9700fc6a31dc02a90fc24a9edaa865cb330fdd768e4ba54f8168
MD5 184ac8272eda61373cd7e08dd2cdd895
BLAKE2b-256 c0fb5b0455bb3523912feabd795e6f4b7ca015a289c36ecb8fd09f2dfa770a95

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 310d4334f1fb72f968ada7ca051834bff11d462beb98adb7dfcf24f46789c42e
MD5 b05006aed05b158975a53d836609a49f
BLAKE2b-256 71b864d597544b34271dd24ee29e50aa92a8aec63a50e0215f7be83697ab22d2

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 767214a6bfd62e5d35219da69908a4b325c76e793d468a05cbc2f491b507187a
MD5 8fa56921aa80650ffd8e252e0dfcd450
BLAKE2b-256 0cc5d47ecc7269ec1b4d88e1bada8f1b333715d5b06999cf394d5cc2a256c69e

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f4249d2053f9d7d1a75de0c073aa4dbef75e14ecc1b285a5aaa9e0764faee8e9
MD5 62266e15a162ccf12c28bb06154fbc8c
BLAKE2b-256 7f3b5fbd5d0c4a831a3a0b3929cf62903c5b3f555d443ce68323853cdb5189bf

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 29a6d8e4d220fc0d79e39bc3b823a0c4072074a6c35f5ce56e51b3a3ddfea9b5
MD5 3bd7c428b4bfacbfa3c984243ca310bf
BLAKE2b-256 13c41fe0d21db38c3fbcbd1ffcdd955a3253e0a759af7ca9f43b50bd419bf86b

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 0dbc41e1571308565eb0c3af7560845331dde0c75a14b96edce3b6a41fdfa967
MD5 0d68fbac21cc44ee1dd912d38bce58b9
BLAKE2b-256 34cb23fcc8f12b3fd33fe85ffecc8260b5b4ec1427ad2bc2c83e2d495547ec1e

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4da70af3f2f440befaeb5e3d37adf806868c6e06241ec3584ba6513c27beb37e
MD5 980889e1f0237237d1f6e7257f012e55
BLAKE2b-256 3dad7dfa15346ac23edca359e3d795a1f2cad06ab38d5a1001741071d3be3ed2

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2e6e0aa56a87e3d5385327ca3552f68430c629ac8d45c30e06fcb8dc7d11e136
MD5 4ee50b8b6bc1e2a11c7230f137beea02
BLAKE2b-256 be79eb428723022d0e1e1cc9ebbebf4a630cd4440326f72f7ea4c6aa46836a34

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 741a0b198563fa089620a34807bbdef2d005f3e4a5fc9c3b79e7924da141497f
MD5 58ec9e22c63f3647f6e87a6628b5f0ad
BLAKE2b-256 f7532b971f38f9764aef166d831cde94c23f13793e792136938b71fec6203a23

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f0c961365971dc86eedcfe032d8ac4b4bd0856756504ae01fb5d0c4ec26fb44e
MD5 95e64f08715eba0b57c512a484067842
BLAKE2b-256 e07f97a413003e88735147f2c9e31ec7fb29754768309ea60587817034ad0d2c

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.15.1.9.dev202409291723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5f5898972b5b8ec8ab8c1c3619d95c5dd0ebb4cb708b0bcea346230d1fc907ce
MD5 1cf291f17c931d93e06b0bed3ff9c291
BLAKE2b-256 fa15f2e9dca4860ee3c584420cf75648a172a686996c7eac948c3599da703c69

See more details on using hashes here.

Supported by

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