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.1.9.dev202409281723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92bfaa0bf38fade3aa42c9c0e66ff23c8d068ea57c73882eed8c4e20adb7b4aa |
|
MD5 | 88f2ed465b9ac7bb5c4e3f764e09b9da |
|
BLAKE2b-256 | 4af029016cbd5538b4257e1b7d3d07712dec9951c1a1afc2e5c31c387043106d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c692224217481201164585488199d511fc7acf41fdacecb2757109757403c46c |
|
MD5 | 566c83696c1086c273f7dddf15b4b0bc |
|
BLAKE2b-256 | ef8f80788b38b526328a487c3c27835a2e9731a2d1ec75379bd64fe0c9ebe9c2 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64ceeb3fb2d154051b34cb5a2f7117776bc5554ffbeb27d4847061368568f614 |
|
MD5 | 4d91749845da186d924234456786f641 |
|
BLAKE2b-256 | 9c9fb9935dda68306f9b773feaf00dcb2c3fb873b90fac54cc1609d27916aaaf |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9733a87867349ddd0391bfe1ed2035242e2646a37160d2e797eae8245745c8af |
|
MD5 | a29b511c96d9c3cc150126158bc50454 |
|
BLAKE2b-256 | 44f0ed13280150336fbaa2cd528a2471f2890a924719748130ef5b148bad4f07 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f830027c2a22127e6637c9c7553f37173ec3bf414d234407bb4ecd4bf9029b42 |
|
MD5 | cb0d259e29704c995d61ee5daff899a1 |
|
BLAKE2b-256 | a552df7646bc9a99464a0f565b67450734bf54c08b48aa3c99e6e27242590623 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5bdf45e8199ad288a75b498f623aaba3c581b925d73be20b4835644ce7240917 |
|
MD5 | 0d9d2ce8d556a5f17eb6ac414140634e |
|
BLAKE2b-256 | af4b58497a0ae360e289f38bfdb91fe9c5ca7f8aa202824409f976a6395cbfcd |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aafb2262dd7f73fcce97f43f7754336a7a3ac77677fe54be1128cffbaf59360f |
|
MD5 | 4f69bf014c1dbc01d10a30b48c9402b3 |
|
BLAKE2b-256 | 17474f21fac70ffa4f5ba59587cb4cbe07b1973dc3e44697f6eeea7e48ca35ea |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b50301d948b952f7bd7fe663a524feb24ab0490889fe4ea37dc4c9c38a286eec |
|
MD5 | 49b11bb6d74c2d5d88b2eba3baaa1e67 |
|
BLAKE2b-256 | bd514f0a15cae6e3e50183637c0ceaa98beae65c4a0d97331a2f0ee9277e27c6 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6197d3f60a80bf8687ccc64f38c664090ec0a838d45f83b027a02d11ea11dd13 |
|
MD5 | 1b944521e6edbe48a44b1c5334c0f25f |
|
BLAKE2b-256 | 423dd0752e7406fad2356058c5c593cd49e6477184247902f7102e638eb8a198 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a5cc0bb17cdd162dc3dc0f987d95ef8d3f8ff017f296bbdb15c18f61bbe4ad9d |
|
MD5 | 4fa76be42eaa6396d86fbac46540353e |
|
BLAKE2b-256 | ebe86502d794c9b16da90cca469f2e80eca2417444961525d454650ef6cfd783 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b780e960036457c53fbd793ac675af88bc1e6c04b8be8d2b859d369bebebfac |
|
MD5 | e823e3a5de848582ed87ce50f16f2f0a |
|
BLAKE2b-256 | 5fd60003820dd40612401fc40fd67cfc2a6ba2eaf0facaabde42cff57f609f2f |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a0d0bc1db741f4465443bf957d6ab140d0ad13022dc6fb8f268d587916ff4ef |
|
MD5 | 3454298b83b22bdf1a2ae7e88fe3acc3 |
|
BLAKE2b-256 | c048d67ca6bad951017a7e12421fa592c834440eb2860a73806f4474cf04f5cc |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 40b63e21e5721e6aca03a9b510b6a34a277154811a6ea38e52923ff7f74155cf |
|
MD5 | c9e92537e60a384ef0a694f00bd21024 |
|
BLAKE2b-256 | 84715ead239dac4394dcf17cde4e3386bf83430b13841691a36a74711b6c6b0f |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5695deb3421a090fd6297950e15a0c3d54aa175f264a748dfd52c6a3e7050078 |
|
MD5 | 381231141601b8e62710d48b1d26891b |
|
BLAKE2b-256 | 7e2209208d3d7c3363e423460c84265a3aef7589effd201c8a05c9b2ef467e64 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409281723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4dddbbcdc16d03adc31edeb433d821236377041c4d1db7ffd328be19ef3ff34d |
|
MD5 | dcc28956f67e9f9d9ffd780ec026b6f9 |
|
BLAKE2b-256 | 8af4af7ae773d39b8d81eb86ae5a6c7ae6b4ae735b6596c391f5bd263b641331 |