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

Uploaded CPython 3.12 Windows x86-64

pyAgrum_nightly-1.16.0.dev202410061727562243-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.dev202410061727562243-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.dev202410061727562243-cp311-cp311-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.11 Windows x86-64

pyAgrum_nightly-1.16.0.dev202410061727562243-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.dev202410061727562243-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.dev202410061727562243-cp310-cp310-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.10 Windows x86-64

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 8565282b9b57f9685abe70c6c4c2e0a85ab5eb4e61a9784258f40552ec0fd261
MD5 03ea321ca3aea5db8c428376083a82fb
BLAKE2b-256 8971a34db28db1b0834935e7fb3593633f0d72ad1cbe17647e44cef924838c79

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 641cbe4afb9d4a33d0d9fd6d4646992893fcc643690bc9e9e09c3a6d89b988dc
MD5 6e1cf403f5228f4224b58e621b43e3c8
BLAKE2b-256 2db6ea331a96b43be5bc148d283c85ddd6b8f1b58d68cabc21158e2ceda73906

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0eebd9cb00a998215ec5fa7bdf174f71c22f0f55bb891c9e834920c941d148b2
MD5 fa393986040aa699d60b4792e6eebf7a
BLAKE2b-256 b7264b572df02188a5673329844f5c1d72eb536a1933e08d245a5383c09cc3d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 530d3c43f95085da95e071d479b7ddd8ae35dc2d314e07af52e9e3ab045e3c8d
MD5 9f40c9cbded104216b20f998ef864474
BLAKE2b-256 ec895a8d50ca3540c86ba5475a9dfd51403ad062a382f6e87e8026eb6afd890c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7872876a7b4b4689795aded8053c1cde4eeef28703b6e1a7dabeacfc2ee42772
MD5 530869f0b445d346912ba8426fbb98c2
BLAKE2b-256 3a48e456da3d40aa8a2e46af666e30aac448ebec11243ed0190d6eb7ca958e55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8e6b0e57d74f206632ad4540b1d676a297449b411cd6fafa34e127b1c49f5534
MD5 fe5ace11970e1a72ac6d3c3165f618b0
BLAKE2b-256 2e2744830effe20a3039c9c20896eb0302a739352a2a1e49aa742c01ae2ad464

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 292c35b92a972fa223e0141993038c13d5dd07827b59ced325b3017b539c7e85
MD5 b19c5944255dc5a26bb3a12c397d821c
BLAKE2b-256 5f43cde326751e1e34fdc3292f4db9b2c06bbc1a87ca2fbf79d9e99ce2981e2c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 01b211e639b97c2e09f3af6fb2585b66b4a7bb6c375edfd9f99917a912889037
MD5 a72121ee0f9de6b2d3f44d1fd9f843b9
BLAKE2b-256 e02ed9c67fe8646fa3179d349a9300f10909dd255d972ca85d7aa653d66a2b56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 71033c94225108d61a9343c81cf5d2f5b3befc18e5be53ab85d74c3d6d539f2b
MD5 e9f6476fdb40811559120cd128a12863
BLAKE2b-256 7cfaf368e85c0e764183481510e66a0d6df8212d64195e0457ad1ae1de11a06f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e76b2dc0f4f950b3065d6cce6f9723a21d8c00840ea3b2dd2f723c610cc4d308
MD5 5457147691c678ab33977a5fa8a86f41
BLAKE2b-256 9ffe8755519a6b749b79f6d647f46902ad6bc22cbf9cf503674fb7ae70a11e84

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 446e31ad9f3a1aeab53f0071cdaa878c5029cd9c3e623c7f110ed94ada7093b6
MD5 ca56e9568535468a99ace87791eeefa2
BLAKE2b-256 7d84909149f01ec2c678b006f96d1e7a96efe8ac12871c6f6e0915b1ba544b75

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 276ad92129beac5047c5c24f652040014da03ce3a946578393f4b82f9e4386ec
MD5 ee02888175420aacd9f9c5512e8852eb
BLAKE2b-256 2dd40672cd4f330bad94894a81cbda69d2cfec8b35837f98c4f015a01c2be1cb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b5dd84ebfbbc30f85be7df003142e04ad130aecd01f31285282b712548f0e128
MD5 a8f8e7ba159f3f592bc292b7b89f0111
BLAKE2b-256 9920badadf2c4d2beec1b35a294928d68e69aa4d63e7275280caaf7c61d9d53e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 09615db2f6ef47c25e53a081b21f152d6ca2c5da2223ea214268b498676a4b15
MD5 24251c1feccdfb06a7121530b35b6259
BLAKE2b-256 ff82b4dfe95ab82cec60c85a462e93cf48f1313adfd05e792b697ccb50ab936c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410061727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1d2b807512d427f3cbb8f538796a7e2d52d926ce2476d58772f84c92b24b58c6
MD5 4923e57637caa76fc1fa07959aec78e5
BLAKE2b-256 8a1c7b5680fcbd14dcb9d40b612e33dd7d8bed6010744169ccb46e5e1dddb036

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