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.
Maintainers
Lionel Torti
Gaspard Ducamp
Project details
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
Built Distributions
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac0cadfb1239c53116b4c6364c3a4da2cc508f00f63c9cb232ffc8998ce0098b |
|
MD5 | 29ee4a310a2b64f49cb55badd69a9817 |
|
BLAKE2b-256 | 845a81cadd69cc5c84b957fb36b1a2f5b0037f697a063b32e6c34a62ef6ee39b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d91eb62ea119ca3d99b32d3e0de2583854e15dbce94484787b5c1c612816052e |
|
MD5 | 37b687ca63ec1a12b49c7a89c0c2f7e1 |
|
BLAKE2b-256 | e54ab4ba67e043dfcfc87312623e2df9708b6ab8a86b70102ef5e2adb4003151 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f387c634d65a91244c000a9c8ad2f7bf2d2ef1b12b8516ab0aa19195753ae523 |
|
MD5 | 493171c3e35c2914927592d5b1d1d6a0 |
|
BLAKE2b-256 | d64000469802a78ae772d340bfb0759b82cadc89ac6a2f9cbdccad826ba0ad35 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25006f746a7718fba407c4cc9eeba6ae535f48f3f58af4bf10ab2a51255b74ad |
|
MD5 | 8c76235f7c000ccaceae446614fc88fa |
|
BLAKE2b-256 | 3c483024fe6408b8f4c361a3f1620d39521f82ec365b42a6f68b1a0a2538c07e |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 599293f5f3a50630df8952fe05fff1fcbcd93afb7dc9042ad313fa4baf4da12a |
|
MD5 | 25d76d483cde307bd0ba2ea31b7af307 |
|
BLAKE2b-256 | 9ba83c164a82fc447e2609ebb7bb1a2b018c70349cfa65281fb04d1b96b735e4 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92dfd57c5cb45f14f0cc5f063a28cfb603d55d2f5e1cd24ca0f91774c8a21577 |
|
MD5 | 3b1bbb657229f6d2804539199055e141 |
|
BLAKE2b-256 | c1ed9b7c356d516bb22897b734da02a64ec2edfdddd6ab90b9db232f713b5c61 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7288d116311256bb2e3fe30b3da0c5dbfc69a6333cb62f3e37541c33e8d3b6c |
|
MD5 | 0d3cf3123950d5a59949b4b7299b355b |
|
BLAKE2b-256 | 950476a29538d8d78b61ed1be6df82d10c57ade09d15602cb81857fb760922c3 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 013c57eae3eb3ca236e7d7b0f48082ec32c6d86684c915b966377613822c2294 |
|
MD5 | 51849c862849ceffa383238b2e25cc6e |
|
BLAKE2b-256 | 8199578704599138eef1a8c41c9c41e20356163dde7616eda33253ac8f251a23 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17821401ebb26e069db6673449e846338d3ce0bd7042ac32ea1393f3e3751a34 |
|
MD5 | 43d8a7c59d33f4311736475b1502b28f |
|
BLAKE2b-256 | 8af07e1ba4a932953706a7fba4a7e6d6f97192bf874259c191c129d654f3d0aa |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7254d41e9eab1d4b371ee051b3f7bb5d6050faae6da12d0c09274e5fad69b7b9 |
|
MD5 | f5a847dd1aeac3f32a86846a2b6570c4 |
|
BLAKE2b-256 | 72b5690e235169c1f7c79bbf46eed0d259d55148a3c2ff57cc193c689910cb75 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20b3bf156fabe8544ae4d5faa9426ca3eb474741da465637513bd60f37a8408d |
|
MD5 | a1eb5d0acfa2a93f25a7b82e5a41507a |
|
BLAKE2b-256 | 54f5a06dcab66d36e3d0223253e93ddbc866c3e70ea902866a3f5b3b22a06cd9 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f62e04471a6356f3f816084870f086084893529507e50fe58dad753db25d254a |
|
MD5 | e6d581a060a2e910728a3ab0cb0b0bf6 |
|
BLAKE2b-256 | 53108e74402e020695128aa6c08c2bb9808d109837fdf63e5685be92af649911 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffbce43fed54622ae4939001882ef78feea1c4643149a044da18c46c19cae6a7 |
|
MD5 | 0e4a732aa4102ed41649968915ca93f1 |
|
BLAKE2b-256 | 219ef50f5c5c6cb8127f9a5c6ef3b3894847e81a463c40abd7ddfa2f6b331c9b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6436e6f0b7d0b4894f77a8903b9ee7563d7d994db75793d493b7450aaa4f482f |
|
MD5 | dac32da75967cafc71196d93491fb10e |
|
BLAKE2b-256 | 0cef2a32554794148607fc0dfaacf3889d2a346b11d82a644954c85729f3b10f |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27e117abfe79cb251205371f12d0e665007d94f367071b62280ef9bdcb3f3e32 |
|
MD5 | aa94a2073c0eba02487eb0a0c5e8fad5 |
|
BLAKE2b-256 | 5396768b716b811e161dc577cde35799b331b876431248fd84c6264b1c85c162 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6ae47b6496e480a94074574e3387fbcc7435b3ef7b7fb5a6882049377f5a347 |
|
MD5 | ef24836d5663f09da53897377a63316b |
|
BLAKE2b-256 | 29147929ef15ea832e8e4aa7436cc71103bd9baf428dfd9cba35efc1383d3bc9 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c8d9cac42912b4a946e0eb775a8d7dd896e0dd642c306f60ad20e356673ab79 |
|
MD5 | fb8bfc96fb93fc87c889dc51f126c27c |
|
BLAKE2b-256 | 0523fd21a167a46115393d1713731bdb88ba8635930e5a98464e7daf53733f3f |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8e765f7531bbff8648ed24857a034b3bf1d21f934d4326aa419ec08c2c0e4645 |
|
MD5 | 83ea790d06a64a00847d4a7bb3fa556b |
|
BLAKE2b-256 | fe97877aae93dad17df1795737ece2e687a662fbda4626ad94a5b8ca4828ab82 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 503d0c3de8e71c385c6e8ba0b65487c2ba2380df8d63b6860ab5701a10561033 |
|
MD5 | 7cabfdcd494afc9f58da28d620cdf569 |
|
BLAKE2b-256 | afa847b90c9b3e46015111c1d1463f704c59a2d635af3a3cb0fd763bb0c61253 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407191721169663-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1a00a96c511b6306f72ae3932133745a5b3ec700129a778bf11dd4b3020d341 |
|
MD5 | 6fd90f0d263b9a671b65aff50884edba |
|
BLAKE2b-256 | 58e7c7e0542cd96ee6e698994bc91d7e11d1e7fa4d422554bd68797b1831c60c |