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

Uploaded CPython 3.12 Windows x86-64

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

Uploaded CPython 3.12 macOS 11.0+ ARM64

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

Uploaded CPython 3.12 macOS 10.9+ x86-64

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 macOS 11.0+ ARM64

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

Uploaded CPython 3.11 macOS 10.9+ x86-64

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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

pyAgrum_nightly-1.16.0.dev202410031727562243-cp310-cp310-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410031727562243-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 517dcd3d851857eab7283c975c1993c7af8ee98a33e0fe1dc42ea196ed69a12b
MD5 b2eee204a10544b309c953727677da7d
BLAKE2b-256 b228e858e34c4380edb47c9b3916cdc2967275a09e9f7eedcd883ec839b613c9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 abf2e7a5ae30a89c153a2acf15342a84ef64d9a584a205470388a04c91a4213d
MD5 14ef08ba2d7cd06cbccfea3984485299
BLAKE2b-256 41b35b90102f143bd699e6cd8bdf456da8805b0571e56297f80177b2cc35881a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 77de12ed5ee9001f54a67acf256e98e446f985fa240bfad3a7aec97b6b4d9cd7
MD5 125fa68e7878442807e0b96b80843b79
BLAKE2b-256 c3b3d95bcd4af18590cc91aab13f82c5673a33262e7a0b14d0de2aa90a852ff2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d7ae234d37b363a8c71cc4b22f81b6592171fc65faf0bec38ac4e1079457140e
MD5 bc9c24e9f25483a2e00735816461f55c
BLAKE2b-256 a14cf06035a5fa68e59e4a6b56bf02ad9ecd29874c8cca8c0c46b0f88599d09d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d5fbc5111578c59c9adb4f3c1a7e8b67d27523706fb661b6416b37732c36cd81
MD5 972903ae268ce37028e0ec09b8f540b9
BLAKE2b-256 160c1813fd099ac7423f357d6dc763241ec18238f925bb656b7546b91e8cfa28

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2aa7489ba87a4f9b3d1c00d3200ad404c8d84a7ede5754d01dc4232908c9007a
MD5 d61a31c9f202f8b43592fdb39cbe0735
BLAKE2b-256 230e248fb16ce266120a7ac1fff3fa371cf4a97b92c837e925153edd72641291

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7512606439985f68ef663e60e253c480ab3a61ef0ae8f6de9337b350824536d6
MD5 f143e1158fe4582f31d55d7bec8535b9
BLAKE2b-256 c7654ca277db1306d5382460984224377e4fbbdb208931d147202aafe154bc9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 60f68159d67cfd496cd40a4f670d8d6b4cbd0f6757d62cb029512374a9b77cf8
MD5 ddd9faa89ba80f3d1d8b8a8a2f3cc42b
BLAKE2b-256 4fdcad87bc24469f48be1ac6740766ae8d5d775863a9737c7c50dcc956143e1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7ed12267c42a862c232e04f98c14c7342ba7bc007bf0b536a22b6c48ea98f484
MD5 947bbc33c2e1aca77a5050e0947a7123
BLAKE2b-256 1112b85ddc49be8193ac9883e935b4de6a9ad6cdbe50233c5e346af417d7ce16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 28ae822cd764dd6137e1532e2c878329d663668e5a0af6002e2a6d068c304d82
MD5 d1f4e82545f111ec00e868c8e5819700
BLAKE2b-256 da769c1973602d542c05b44b16109cd241e28668992c2166868e45e1b7015ba5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 25ddeb65353882e35e8b1f2fdba45322d5a06e2ab918b7bde7320e0cc77518ae
MD5 34329601c25568c8f011da0cfd314f73
BLAKE2b-256 55473866bb299312ec978307a5146630c2d66081025d962cbb81a24cc151bacd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1e458a5130633188f3c9c15972c088fef8ce632acfdc5ed9525d954f0fca5b6b
MD5 c896568268a520e1e6bf6454f7e49463
BLAKE2b-256 946e84fac9ed755cf845cec2181f42001919a6421f0c5524717e49d9b219a740

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9d1c7806abbd02ec281c20f492fe9a2b12d725ffeaa674bb33dc2ac08d16e7cc
MD5 b7a79a8ac6c53ed9b10fb657080fb556
BLAKE2b-256 610a4f04d047202084c39f197422e9a8653e93faa5e52716d16e0f9e1facfc96

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1fb4f5b4c9ef502f7b5a5e84aceee22c5a6c3dcb679e741fd69a3442ca28648e
MD5 463d13066f47617c23db238cf3037b1d
BLAKE2b-256 ec2eaf936bb922961d72fa003d2da11b14d45dd5b0bf6833bbf5cb4c18be2abb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410031727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5d4ffcccfe0ab1d2cbade5707039660ecdfb5f6eb924eef65123069812b74bbd
MD5 4f339e013f5efd8047810e84205c48e6
BLAKE2b-256 dfbda9e16817b6d5f4b5b19fd059a45b4d3f0c82bff6aff8bed2715f69b407e0

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