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.dev202408021721169663-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 60d84ad461ef9dafc52bf24fbc47014d93af167ed1d54dc91dca7c30ba31a12d |
|
MD5 | 33f5086024b66ed3261f1b3effe36741 |
|
BLAKE2b-256 | cbb7118193ed990f893f3be1b5e46d764669a1afb887122221255f2512fa2d9d |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ca01d6e8094fb92dce7de20356e2dd7764301ac5f9a2376620cd804d4503b8d |
|
MD5 | 19ee7405d1d305e366dbdcaa750b42db |
|
BLAKE2b-256 | 1ca5dee822d97e2768bc3471efd59910f22255d95d107d9a7bda7bb788a924b9 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 271174cdb447e87ef9e3f316af57552f5de3a5be9a46fea0e3ed4251b116d76a |
|
MD5 | 14892603312068386ef22ea166dd5c7b |
|
BLAKE2b-256 | d9b3cf307bd210751f6ec1db881cab0c3252e47484efed30c12f434572b92dc1 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bad2ea0ea6aa7711300cfe9cbbbf0516ed3a9b3d103ac0cd482542cbde3bcc5 |
|
MD5 | d565cd948e2a97a934dad7a72646d5e7 |
|
BLAKE2b-256 | bffecd6a805175a84f5cfcaa261b6f7bf716955270965ed9077b1efb370b599b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f87a993af40ad490e14f2887b1d0daac8b1fcef80f75cf307579871defb38702 |
|
MD5 | 8dddf46463397a81264096254bd4a120 |
|
BLAKE2b-256 | d198dba7d62d49179912bd62a963075ca3b796030b0025af3e112e0378561640 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea03ae1b9c8ced705d71237906f6719b21a289e62935395641cc15992513417d |
|
MD5 | f574837eb62018e19c2a83862394bb58 |
|
BLAKE2b-256 | 5ddc8d464004bb73ec3cf284e08fcc51908f6dcc33faaf6e549b195a91d5c43b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07695ec53e93c551ba38940816b7854320147113d191553cf8169b453a9c3b49 |
|
MD5 | b3b94b651cb05709e12a4cc63ce4b518 |
|
BLAKE2b-256 | cee36694b033fffd27605eab0b25aa862b414f4b167bb024b02254caddac917e |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 002f65ae92f73cff80b9431e06cf8b401754eb79d3ee72220db0da0f885694af |
|
MD5 | 570431f196eb14ebb02daac32eccaa69 |
|
BLAKE2b-256 | 46e5a9558c6aa6737b96c7ad9013fb53fc5a64a4970d8fedff272be18b6ac45e |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 823c6221f301b1c362cf678ff0f7817ce81a251e6731fce85958b7fe3fbb8d28 |
|
MD5 | f655e686c1ab498367435f35177a5e45 |
|
BLAKE2b-256 | a489f7d444d2d6bd2ad4076abf1d069887eb9f28eb8674fda1bb8e4b0a2303d1 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92db92e1009f61b8a21c4e461cd9fba5153a1345847642ccc905e1635f0a0628 |
|
MD5 | 1cca5f3bff52ece484c7ba62df8321af |
|
BLAKE2b-256 | fab363de7687d5ebb58d6710690c5e6e22822f89c2126854d98a17276c7fc442 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd260a282b3c8345c9b815b3786e83c0fbe2322482e3218546b651da62cc213f |
|
MD5 | 7ad40cb3e8e7a0b4d1dd96665b35e05f |
|
BLAKE2b-256 | be4a76f725598a2dabecfcf69863314a68d6701a7f90c6f754b402c3ce0c2b4d |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c4ae2f42e353b385920d7bf34ad2c9e4b27a875d8193a07634cfebd5e1a3d6e6 |
|
MD5 | 204e5884d99632cd75f30ac79bd4fea6 |
|
BLAKE2b-256 | e990383467b3cb45b28129be21d6c0b60efe31771be16fea9ce60bf53f288a95 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 20c4ca070a9994d3da0af0298c3fe1f5b4f837dce5157a2538010f72d6926127 |
|
MD5 | 629b940dff9eaf1cf05466495fc0ee7d |
|
BLAKE2b-256 | 43406124e741e70e685951bae70eec7f5c83cc77fdc9673f2677775b9a0fbb2e |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 335bbde3e123147936ed9f9ef09573f59aecfba4d6d2801331641bc5cbd017c5 |
|
MD5 | dde8dd788b10a71955915ad5b5148b0c |
|
BLAKE2b-256 | cfdd252af6b80e577bbc5c8267ea8d29aca1a1bbc47f93f76c8c2b0e19093e3c |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 690bdbc15c0e6bc219912244a75da7f1f1de092497e072ce5af6221cf0aaf88a |
|
MD5 | 3160be32fd9922ac941e1ec7a1205cec |
|
BLAKE2b-256 | 83cc7535e2946c265564f6da3f0948cec5ddd99f27cad3e910d3d298f9969604 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24fac4b26e125d4eac707b2563836d5bee864b8dd747f92a67e01feaa39cd506 |
|
MD5 | aac214d8fa32f4044c25f1b214eee843 |
|
BLAKE2b-256 | b12b139d5eef8533985a0a4e2de2dc73201acf82115f395c02a6f4c3113d44b7 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d55a9bbdc5d1a0c4b28ceea59d9f4d997e84752b5b6a906aeb85cdf285c506f3 |
|
MD5 | 8b9572cb31b3ed85c4f93da46017f8cd |
|
BLAKE2b-256 | f59f99dbef4de443f98f8db445e7efd763b2699aad141875cdb09ea8e53e2cbf |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff818be8f0f51f0b93973f3f0a54c4221bc41beb59c45ee9ac464401bb430fc0 |
|
MD5 | b730666c08a58235f7da5298c86c42d8 |
|
BLAKE2b-256 | 233605689c12d73b47454cdc3d4fa3042622542dc43974b562a9c1f7f47911ce |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8bb879f721397a897c21b77e28d68419f98dbc57464f9df2ac11d1b277c3c2e |
|
MD5 | 35a387d923f266a661915ecb9b552bcd |
|
BLAKE2b-256 | 5620f4a7e622f10a8be6d8d195c56ededb094748d23c2edd8e06756e5a145b43 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202408021721169663-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb480df4ce794c877c4d2d4bec289945f458c935b745ad1c1e9b8f173f212af5 |
|
MD5 | c3178b18e350b7ba54cb64218d3b4744 |
|
BLAKE2b-256 | 8b994199d4f1f2aadf10b5ef1c9391aaab9084a12f138fc84014e4d5cddf8bd8 |