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.dev202409261723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c57b8833af6cae28f4d6e132e3cbc1524d5a11e540bec4ab55af95d606cea90 |
|
MD5 | 7253ca2b7fceaa68e6e26f4582b9537f |
|
BLAKE2b-256 | 5bb2f1461d44d460c7db158eb0e5ed898eb58c028e9fd06f4ba8550c8f544055 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b4419244a4395153f5f3c64dc782cba3f9830375424995f6fad8a833c62a7c3 |
|
MD5 | 8274afc32e0ac2958cef1e1858cb75d6 |
|
BLAKE2b-256 | 02d23dc2ff762d41bb097f056349275114246b1df48d26df34f15714606a3f6a |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 538c838bb4c52571dfcc268607c6a92b8ff268406d0a9b590fc47b0ed9ba2970 |
|
MD5 | ba3f87a215c3b0da23b3100d6ca9d13e |
|
BLAKE2b-256 | 4a16339f3d0855d7808b259927dc70ae5c9f910e86ffecc1d54843bad8e91316 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | beec8a0daa5a940f6981bf7fc406e02e1a2f087895cef0b024c1bb6a45e644af |
|
MD5 | 0ae4b7f2794648e68466380db25d76bc |
|
BLAKE2b-256 | dc1e1332e0f6f378ba1cac048d7ec15fc8d4cb907ea2402e0be0bdd523b86da9 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8817201e14c26fd59a69f4cfc4bf75bd440f7e38e73169e32552e5cf8525a75a |
|
MD5 | 5040cde0a7248eb0b7e53e1d7e5bd869 |
|
BLAKE2b-256 | 20d413cb0212b830bf85f7e42e1267b949225a79932f6ca1e7b64c04536f1cf7 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dd6b27e07fbea187d46419418b4a7b1ffec6b3c55fa7013fb6e74af4f8587e0e |
|
MD5 | 603246bdc3ab17e6a510beb22af07d33 |
|
BLAKE2b-256 | 7f843c23feb156ba9b00b6625a23c33fb004a13baa84108bc9a31a5e591ae774 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bad49c7c4b394ba0c7345914a75b3fbe0702ec80b6310a67be9ecedbfeace32b |
|
MD5 | 41244e7d0879adededbb6e24ce28e889 |
|
BLAKE2b-256 | d4193564e62c99c3fb28cf562c2d8cd2b8da46a3b113b5799c71106ccc27cd27 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d7fb554541e2cd0931d992e3b8d0655ef64f99100991bfde4bace2d00567fbd |
|
MD5 | e1205d925ccdb6be0cee5d5eac7e1e8d |
|
BLAKE2b-256 | 4251d095d0486b337dd58c429f29995a50e499686c908da372a8aa89efb3f06b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e57e8497985b61bb373fa1a801f4f26511f21843992894544613882e62100d7 |
|
MD5 | ff35f8800dfd428ca8c01ff0af05db5f |
|
BLAKE2b-256 | 695d1e9555a480fa99044c7a7f94f80af5f108600e1486334b4045f2f3117220 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5138617006a39a900d738b88fa2270e0ab904446eaff67f4f68ebe70065de96a |
|
MD5 | 7674a44b59769da2b9fca0067fde4eff |
|
BLAKE2b-256 | f35a9b67c5142b0d189a8651d02584255ec7e7901a7298d72a79f7777570141f |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d81657c5d2848815c9d8e402841f39129b72e46b54d28a2b6aa7a5381037fc8f |
|
MD5 | c5d35adc4a907c51fbf049f7d2f27c88 |
|
BLAKE2b-256 | 3a921ad1ce3c0bfb5b68012f2d587ea93c5ab9cd8d2a03e3bb6b5c9af1f40f0d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c50577ace3cede6e3860774e4fec2f5d25a79c9ccd3c9b6dd8df47b19214b890 |
|
MD5 | 833a2f76a37c3a09789562f58e9686d6 |
|
BLAKE2b-256 | c78991d00dc810bc269d0e1dfb960cc55c56f3ee60dfd7bf55db047b3949306b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffb83a6904eb8614a26550a6ec1d0c59e49e13fce772260c1c139c98ce6e25ac |
|
MD5 | f83cc9a0e957846498bb1468dacc7b31 |
|
BLAKE2b-256 | 3072136aec57dd98074da7ad7af4975ebf11bde69dcf457ee2bf25ffd36c2e63 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12145673007af48c0e8dfb4e78255e6fd5ece5f082a6c2155bf197f4fc2cb63b |
|
MD5 | ef9230ad20acd78a4ac8d38a09412aa9 |
|
BLAKE2b-256 | bec6d2203789a40cff40970c9162a9f564c799d5df062bcc69d717b2ef11e426 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409261723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e77707de20bcc17731aa857091875d8f236700ec0cc2585e3aa6dcb11bea00c |
|
MD5 | acec8e9425834b3519ac47b8956d21c1 |
|
BLAKE2b-256 | e4da81f2ecd00f6b48f5b0b9690a24ef4a9c643580fbe5eb6e1f6a7eb3897a2e |