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.dev202408081721169663-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2549388d2dc19eae4108df653a31887c9db6beb049d8b8984dc8ffbd5c12feea |
|
MD5 | cc910f3eac628b16e6355c6c1a37a75c |
|
BLAKE2b-256 | dd23230122c3141ca01442c542e2ab2471c7f337e100b22bc2350ae250370f7f |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1a48251ea16c5f5c8e8e93c84f28ec91433f1bcf96791edab5e163d70d6d434 |
|
MD5 | f5444bd93061d299e2f01d5492196478 |
|
BLAKE2b-256 | a873a79641ca20c0397cc87788b8c761bee44b566748bfeaab8e6ad61687a43b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 357a743e6e3a16d9180a25cc34c515676c09c7697870b67afcd4996c922ffed0 |
|
MD5 | 6f6a79a91eb65881e2b798b3d001baaa |
|
BLAKE2b-256 | 753affaa0c88d9b5e5c75cff806f3436cedd99c4beb5220ad8720c4683d5cc66 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab5e1652fa6703b43f5700007bf1900df58b7bb7017ea0661bc6fceef1c96640 |
|
MD5 | 0a362fdffaa226d6e10bd9922a89b401 |
|
BLAKE2b-256 | 8155d06bcae050a0f2d177f22c716fc5c0ea037ed66c6a1020fc0626fc167e63 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac72399339ffdfc2d64331e4f453113155db7700857e52840c7a3e21414c3791 |
|
MD5 | daeec7468cb059f985acd088aa250664 |
|
BLAKE2b-256 | ca8d38110268d5fb9c2d130c608ca706b95ea8fce386c90bad439366b273c61a |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5a12d7c2456ad4e4a1af8b8590e0b3f0ae49621a2d30c715bc78708e820b0a93 |
|
MD5 | 1c6c6c06ad8e6d8e4896030a1d247ff3 |
|
BLAKE2b-256 | ac3b77fb90810ca91356db3769bbfb3ffdb6d6411e140633b3b10988174d4709 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec7f5d19520fcc5e7dd29c20393ecedb84a0e8e7f05ca1307908ce66da378a88 |
|
MD5 | 9c349ebd783fb860af8a44028164e139 |
|
BLAKE2b-256 | 025700e7604509c46d42ad2503c5ca370dac06ae7ee866bb77235738652da4f7 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 959a2b82e59f1c40fc33e3254c3ea00e51b8a832a37e4cf8badddee849b797e1 |
|
MD5 | 24a825df7ba4a9352f39bba85ea1aa36 |
|
BLAKE2b-256 | 1b27b9caa7fa6cc2404d3c8268c000d65f6f57defa0099cc7249f58f37f89e4d |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0edab360554ce4aed77042fcb907bf79672746e4f510d28449472963c7fc6d29 |
|
MD5 | 9854ef8e758ea731e585b65a0bbcc0a9 |
|
BLAKE2b-256 | b1252b237fb366c3a9337708faf7ccccd591f4d92c2f2e09d20d331252a9617f |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dae96888f02ffb0299cf7162046ccd2759cab30d83fe13acf3823fdaa0c6577 |
|
MD5 | 53eb5fc1db86a171c533f0a133987b5d |
|
BLAKE2b-256 | 4e964a4e1bef7748b25033d601d93a5127a528f7a58bab8b5878db7653efee9f |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d760c38e841f5cf1322f44f53941237db2f8116f801c39aecaf655f61523b2ec |
|
MD5 | 7269eb94f783167af85deef26f9dc176 |
|
BLAKE2b-256 | 8a8baab22759eef003a973711c090d4664226d10d92bea34bc37cc32ebe4ac04 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1a64282f47eebd411d3fdc66c9472a4c899620799ba751de93efc973ddef7224 |
|
MD5 | 6d784c3f6f4dae4f83cca4c1148365ba |
|
BLAKE2b-256 | a1d09fd4f556173b755348e2e310ba1e5d517389208e2e476f5b5e7c16ef6549 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ba6d643e1097765eedfece4eaaf7533e36f004d3b30cf9406b27cdd868949e0 |
|
MD5 | 54f6d6dabb3936bc49e30bf383c4526f |
|
BLAKE2b-256 | a24e8e92795ac83f53c89214bedbcfb2a2b4e2295895dce3053a52e83574bad6 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94a882611ee965ecfc9a2e407a8ac50d76db7c5f263eef32452ecd9fa836a7e2 |
|
MD5 | 03ba76df8db7116582e2770cee0c79d0 |
|
BLAKE2b-256 | 1526037b556832a59bd2d41fd376ef0a310b81975cd9aa34dc5a3598df271b66 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f6775be378a8e3602431899aa28b171863b14a6c9e3f80d3a1069550cc1f66a |
|
MD5 | 74b93a98b422eaeed33aa8d3d4bb9a25 |
|
BLAKE2b-256 | be37d7e83f3617e97b579c83017e2870f560002daa6ee58765afcc46f62cd996 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 727309ac64857238ffb4decf10a1b6d27ca5887f208eaaab4812895ce63dc0e0 |
|
MD5 | 260972433d356f750cac7a7d0e7e820b |
|
BLAKE2b-256 | 51bb7f5817959f8bc7c381bfc14a38979a7be7abf733d97971847d95db330c2b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d04fdd56bbd6a00a72adb1e50671248fc8f45a0cbf0ada8a414277bcb281d81b |
|
MD5 | 72bcfc90d0149ddac7934c56bf8e6fb1 |
|
BLAKE2b-256 | 41a5083c3a4308b2932eb8fc5ae0a452c3f69e1c1701dbdd9ddedec498578eb0 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b5cfe7216b9fa76dcb6862aeb4ac7591b0c01b07d437a1cad624505e5df9b72 |
|
MD5 | 9f31c0888df49334a1a917c89f5304f5 |
|
BLAKE2b-256 | 02c88531e148884199e460dac58d53eee2ab2844710d7fddfeb1a957a95e1b51 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de7583e330afd79a264bdc7eb7fdf303851ec5f4142b8a1f7dd6c832e3dd3819 |
|
MD5 | 2ec1c82ef6386439425bdbcbb976c054 |
|
BLAKE2b-256 | 8ca332ad90a202ea6bc54699d3682225797d388ce0a0a4eee85391bff86f7c5f |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408081721169663-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1c4f9b53a63d385b8145b648a8a0226f0bed1f6884b18ba68368ed2f729a075 |
|
MD5 | 9e32243aa6609bf2d2492c856c9bfc73 |
|
BLAKE2b-256 | 28b2c790498589bff28b683dd30b6938aaf9051a12c099bf694efb25f832a3ff |