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

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

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

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

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

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 0411f30a1d999895571bccee9e882b5cde0b0c20ab5a9f26844e1dde57010114
MD5 fef94ff0a385b8031780cca70aef4ded
BLAKE2b-256 52697587b859decdff851eaa3386592f7864306704919b19a3fecd624226c43c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d977e2e2fe50f416d0b4be8a831f2ac8841148d3549a9b0801a948dac6add691
MD5 30be54c4100b1ae09d026b160ca0664a
BLAKE2b-256 9d1d70cb43ed522da348f2766db2ba6322b5434c9dff503a38245b167af766a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 121c2e93782a0f4b8c70d9e875139c4539cb70992fb4ec0cbd278229fe465b8b
MD5 10d04388d92748a7ad380681a660b916
BLAKE2b-256 43db7ebf50a9d2fa2e7f9c44f06774b2dd4842e4f1a2f92499cceafaee201a32

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4c01f46fff71f85495d55183903fcaa97ec3f9cfd280a3dfa591a9b2ab719d14
MD5 a536fd38b8e3d12ea4211126869fff91
BLAKE2b-256 b2a3729ca9f45b2d427cd6ae127a6b84b4b068453c1765deb31ebe81067baf39

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1591fb35fd2e22dec9eb2568168ea4192ef8c1f3682b4aa4cdf1e8e829266e18
MD5 9e6f64c2ce391f7db9baca263ccee950
BLAKE2b-256 3799423c46502f34192ba969892d4db55291dff376e54e380f2535c9a34643f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e02dbdd251f179f309660583b21f0b60b5cb90c3943874218ae9351c6a08026f
MD5 ba81c8a5acc8baa510a05b433de748a0
BLAKE2b-256 c80985219ac6148dc413a014adddb4330fb4b66280163e569b61821fb65f27e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 633f5e3d3be67f18bfa2655f3a06992bcee1d25062dd370420ae59141b23781d
MD5 a403331f0eb502a973054df4d8bc31e1
BLAKE2b-256 078688c4ac65411edde1a6b599d255dccfefa15932c499407cacdc09ebc53580

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ee595064c791b1fb1bb4a360dee7cfc9ed911a378d697a9a620da07e7111c00b
MD5 33b118e446999fb541e54457d3bce54d
BLAKE2b-256 c9f5c306606638bb6c3597d375f4614f557c2fd87db9e20dfc181e0ffac50ef5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 06128fcdb4324f5b6644ce8ed0b167114bf0ba9496b31c0b0e3b544a61fa0bfb
MD5 a3f75aad1fd8da674a63a303e3f34c25
BLAKE2b-256 86463f89d16dfdb09eba48ea6e301b4492b813f3e2718f690e92453927227272

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 491aaaf3808b93d2461c70d0fce921967569524537f4061d3e498c942ee96435
MD5 8ae0d3a4cbe21d3a750a50122f200a32
BLAKE2b-256 89b3ac0e6f4bbc8a4b806e22cdc74336cdd7fcda2b4fddecdaf71277631a85c8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 21a8471ac81c41510ff06376bd5d01fb95013fb005e20e086484d0cde6ccc9c3
MD5 fc3ab51a1b8d023fb6c6bc67fde399e7
BLAKE2b-256 3a44699d0725e9fbae2e1cd46de8ca2fc352b575fa5c3a08a8f2fa1ae8a2f753

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c971af1c8251995fb274b42a124f74f683c2c2b606e022495671bfe3f6760428
MD5 cc5f6977b2fc57f87adc5a168301d7a2
BLAKE2b-256 87fb07144919d149605166a01c7d82c5bf04c7226071a28fb3baa8202812c1b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 74caab206d5390d647271523bbe24e302b5e6002e1c9c1f1ce5ea273e8fe8377
MD5 b677ae13abef54c7c17568b6e50b6a88
BLAKE2b-256 856431f1ddfcad98cd4dc8554f9bb37ff7f98744389ef925b0e03a9f3d923909

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 83195152f0448eaa1b6a380086b8bfc6259c397afb621b283cd90f6694c1547c
MD5 95bc6481f759631b106d76395a818875
BLAKE2b-256 75ff49660b749d2318dc634c50c583301489331e309c5eea1208ab187e9cff55

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410131727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8ff82f8b41f071ffc467c24c0934abaa33bcfba48cefbcce4fd0098526674706
MD5 6a1976190407aff7cfa86583f7375eea
BLAKE2b-256 5430e280f765d0b60e67224c927803acd987a9591aaac178c0c39f1f2ef51896

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