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.dev202408221723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18465a3fabb4b18baf67d5784118053228986e40bdb2aea3bcf5a9a010be8ff9 |
|
MD5 | 9b16329537078980f4b90f5be5696df9 |
|
BLAKE2b-256 | e0d8f550a8edea80031eada4daefb0fa921f8a21d1ac4665c5ecf0805ec0fc7d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d8fcaa47b25f8f39f7b9cbc740998e19b7b5ac17907925c5795411a98075e03 |
|
MD5 | e286a702e15ae2aedef7195e9ef5a80e |
|
BLAKE2b-256 | af11288d1847b999ba462158648e9ce2924de060bf881ab04c8d94086fdf8d7b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | afa7870e195f82334cc0326d321fde45f5140de4bbfa7feb89355f139b430e4d |
|
MD5 | b1ce8aaf20977194919baa0782953392 |
|
BLAKE2b-256 | 93d2a35e7a2ec0e404b9ef05263a8f226cdcc4538fc6263ed98531a9db6f75da |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82435bb9c4223bd933aff67fab7486dc4e88b98a6670be9ffda69e3c8a5dc49b |
|
MD5 | 11a8f18ce77480c15487ff3bc437bc6f |
|
BLAKE2b-256 | 7638d2829bdb6e0e609d91c87640761400b583372642ab4669e5b1d0bd71583d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e35d71f75a3577c534262997e03c1bdffa40940ec0d66a92d44ac69a6d443a7 |
|
MD5 | 69f04a3c740a4ae3985df11f2e4ab76f |
|
BLAKE2b-256 | 0795ebf09efb2381fd20ad3d2a597525a86dcbbb2cb403dccbdf3917e36abca0 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be4b4d1a4aff00431ef4791ac299588a1834d0e0728165956a7c6c8278d045c4 |
|
MD5 | f13f5d4308174ab9a00a4c406dcccb9d |
|
BLAKE2b-256 | 84b7202a9377fbeb046968b081ccd178fda09b4e73c3201522861ba0945ffbfd |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c480524556d01fbcb99d18a0dcd5e6bd213243d1ec71140763d9544305229fde |
|
MD5 | cf26dd480ec97b9015c9c0fd4e970a2e |
|
BLAKE2b-256 | 0e3530db9f305e99fe2362c6dade818434821b57df28574dae5256e9bbf7a955 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ab3e40e443bb78d824f5547eaddf0c0721f6be1b18014e0b4231a891cf2f0bc |
|
MD5 | b0ca5cf3ed7642c32da520c954e33bc6 |
|
BLAKE2b-256 | c446ce311004532b961be72014843dd7eaa972403d96518ed6c7cb7c36168e46 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14dff32a86425c6d10ce919b104b4c40f46808a8b1af8e7c7a6315bd5036d666 |
|
MD5 | 35dba0c6e8b2ff34a6ca29f4800c0218 |
|
BLAKE2b-256 | 6f844b227379429ceafae7f57e5bc51018f0f8c9edd45eaf5ff96308834e235d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d985fc28592dc1faa0db3ecd8ece1e08fadb197b75e13d9aec52a0fa0d973f85 |
|
MD5 | 03fa057042e77d54be080162c233ee9f |
|
BLAKE2b-256 | b60c9b17a614e049f4d8c46aa4b7ec5ae40afc3d748228c121582ebba3919c83 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b4895a0c025817de65adee6157b85f50cbadcd86da42801fe7bdc6dbb938d1e |
|
MD5 | 1947fbd5d40e8059fb86da73c85eb0f3 |
|
BLAKE2b-256 | b852cd9bec677f650316c4f96d15fa70fe108f39bd80a2573a7bc7e5fe94d7d3 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 38bcd8a302a098cb7d5a9863ddc2ef3b29ac8a36a5c5329e1574091d68ec3033 |
|
MD5 | 40ba7ea773ababf18ae6a60dc54b2358 |
|
BLAKE2b-256 | d37ef6982932c3099adb26a5ae158410ebf54822f8e1b1fb1dc188b0839dd474 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 483c0456846d6352173d7dcf05851a82ab19607ad8c4105653b7691551f66662 |
|
MD5 | 29db180957ec91dcef91329ede9385b0 |
|
BLAKE2b-256 | a716e2715ecfb41c4cd2b21e2ba63fb28aff2ceaeea78d018d40fbb96b6d6d78 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67267bad5abeb77a80815e34f35456ce6fb4aea69acac38a35fea69a0efee572 |
|
MD5 | 5f3ed66bdc028b872bb29c84e64eabdb |
|
BLAKE2b-256 | b4f4b4b56fb93756a4f9f1f490e3b6a13cc35294aebe510fd8c91909a634f7ad |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a9157828277df16e73b04434d54b3e19d806aca4a0639cdf4feaa8d9ad3ab6a |
|
MD5 | 8a381d3375ea30bc82d0e6d8aada7cc8 |
|
BLAKE2b-256 | 8aba3034bf55d52d1a7b005c66fd696110847977aec8a3f0b5278177b9f3d717 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f031d96d0135033875ddff9f23373a038fc232bf3b5d773f026a1c6d79d84865 |
|
MD5 | e49a8571737a9466eaa0e6c5046c902f |
|
BLAKE2b-256 | 13cdfda97d7b28d0324d013cef1579eabc966edab01c0f73d85599839841c8ef |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d70340b4240f19d792252ab0b4296190918057b65441b135f7e46f404eae9ad4 |
|
MD5 | d6c6546bedaac0d0b1af87548cc5198e |
|
BLAKE2b-256 | e1c83b2248c4f838ae791d51eb3650c3e4f3690d863892ec0cbbb63cf1f14383 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfe054f840987ba9c27c053949e6d90c6fd6fbe0ba3f72e7192843a4b314d2cd |
|
MD5 | 301a77d11ca91aa8409433d540e05770 |
|
BLAKE2b-256 | b267ec5f8f4168109b60331cf589aedbc6d21adf89f6a6a0537e4684ede47440 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7c937be2729f8564c8de2b0cfff91490f67ee2a5640b67e0125d9784d0e0051 |
|
MD5 | abe6745236a553d54b6bcfb587363357 |
|
BLAKE2b-256 | da5e400a6e0c9bd46a7c583b997e4eb74682cf131fcc93e4b31017e1cf32d024 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408221723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33aad3d0b5cf0ff282ab6df5926fdd97d17c833a6181c893b05c733d20fd77ae |
|
MD5 | f863d9f711a5f0b668ba82e0189ca4b5 |
|
BLAKE2b-256 | 29b768a6b69503108c047064d53ee90319ad2f1f6a499cb9a0a25f9a410a3779 |