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.16.0.dev202410081727562243-cp312-cp312-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.12Windows x86-64

pyAgrum_nightly-1.16.0.dev202410081727562243-cp312-cp312-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyAgrum_nightly-1.16.0.dev202410081727562243-cp312-cp312-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.11Windows x86-64

pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.10Windows x86-64

pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyAgrum_nightly-1.16.0.dev202410081727562243-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.16.0.dev202410081727562243-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 374e2b9eef476e57766692918599f8275a80638b205b90bf789f4273e16873c2
MD5 e52b08373f61d9e0a4c168cbbb2107ea
BLAKE2b-256 7e182c4c436181142409b3aea61e9d82986e088216f266cf9171a4ffdfb6f275

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fb3238631e022a6ad1dfc88303a1b7d348afec1c9642211253bfa486261cf119
MD5 7dd9e383cf0a69ecad09a7aa1bc2d3d5
BLAKE2b-256 d57ee7e4768f406260fa873daf7232a8805238ec27d22149b0390249f5d61e73

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp312-cp312-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7299acce02bbaeae557893cd78edd0618e929a4ede675910c3daea010a51042a
MD5 cb3e0a0333c939c99841fc9003762cb8
BLAKE2b-256 45cadbf10c9ba6ade171206dd95d4126c2edcf506953dd36e255ae702a07579d

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b960d166133ecad281665b46e2eade78b50e486101c15a19069a2f0527ec514c
MD5 61a9c290de5776e8ea1c9e75c63c1556
BLAKE2b-256 07a3639bf17805d24de93c50de19ce368c5cd01e610efadceaa33a3985d51191

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8ec10eefdf999e7e2910698279d8e02262b2c981143e7264634fc236a385e0f7
MD5 959a58bf6c819c4c98f43e7856e16587
BLAKE2b-256 b4f5275cae680ff56219c606391de37b678fd6b47e7e7550a7deaa0ea33ec666

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4d5640a1ba486f4bb7bde5a1efbb4308abe31506273e8175e468a0cf83770fb4
MD5 7ad6d67eae3fd4b4e9015b790ec76d18
BLAKE2b-256 e4c3a5bc6b1460901d453d95540ed6509df519b1a162c25906519b982110a639

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2230004472261477e566785c337d6e7e5a633669f742a23f28d08090ffe7a421
MD5 b3a08b6b2c08bab1ff0a649ab0d1379e
BLAKE2b-256 00f38160ebc91b42b976523b77aca56ce9d5946931248c0acc29b6238fa92b1f

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 909335d8567f86184a7f1c37c6d6e81023d32cde947177633a9e317d0d6d2eff
MD5 c16f015a59fc80db4bb91520e7666476
BLAKE2b-256 9f633124a18eed369ac7d14bde951d9607137c2bc23aa52d0bcc6008842aee90

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1c630e61b30d54ca221267b862f7a2e059afb24641a24c224efa1ecc3409c7d3
MD5 ba5e136171755e1966de6537354ed9c7
BLAKE2b-256 e740a310efb08637260a996a0a1baae9f359428ed33c40bfb246da17cef642c9

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1b56d3c6c4af77334627d641da749885667e9fa9ed65312775d983b351801419
MD5 c56a590ad651645f7be0786a88e2dc02
BLAKE2b-256 88a0fa4ad58fb0e6429b3324c0f176247cf346208630bc2e1da5c2ef4f939c00

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4fab184ff9b33badfe0323d6cbbe75654dafd56f2d2aba3dc9996e67d12a1fcb
MD5 be7368cb698abbdbeb86c808845ac60f
BLAKE2b-256 fec924e9888456b3a829b4b71d6c2503701a78248c34831f9468966b403bc5b6

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4ef9d19822a075b770b3cfd92aac95cc63cb5ef715ac3623c15d3db0560ce9db
MD5 9a679f6a67ed025ab29112f0b93b2660
BLAKE2b-256 f0d05ea262b13efc8e9086aae3dba8365261b6fb809f5cebbbb5913e6690ee82

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b801cef2b0779a62596afc3b27d374f18789b3da8f43c6b0262674dd7db17e08
MD5 1059c87becd1427aba7a2a6a676cc08b
BLAKE2b-256 fd68e53059824ea9bde030eb58deeb390b1e541f8009ae1060bd0214590eaf55

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9df0bf256bc9d94e93bd20e950a98a9e87ecfaeb68381641f674dbc6290bf60b
MD5 81b0f28f89d6d51cd3884d7c15e09d6b
BLAKE2b-256 07309b15100b4d2ddfb05995f4c96c549b735814d4af05ffed5731a853054a67

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410081727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5c22be2dc9e3a344f28feeac0da9bbca2477f69474d8014182e43093c101cecc
MD5 3dd1780b8aa167213c368b957a2c2c61
BLAKE2b-256 b36530db958ea180cf1020e11ff25a93c949f9e9804584796804a790536b7e4e

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