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.17.0.dev202410231729615378-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72fbc6035e6dbb2934c5c1ed94b642f3c4a1b1f97581a88b95970df1f1dcebb6 |
|
MD5 | 599b7e169f9e4865d352810b7e254b9b |
|
BLAKE2b-256 | 6e75f607cdc0a7bbb4dd994d256c8d1b14fb91e67964f379a4928772a69ae63f |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp313-cp313-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 298fadd2375d44e261b3f31e6e5424d1ada79148a3dc38425d528a532b611967 |
|
MD5 | c6bbab1a612f109b32f19b4ae33b1c0d |
|
BLAKE2b-256 | fc2ad2982c07c274d701573a5a76a4f2ee5b83faa07377d70a99290f21db0f98 |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp313-cp313-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1eb213b2378637355a69b720e0a4c9759b809ebd5f19456b959b18e646e4e36a |
|
MD5 | 34fb8de05aeb5b92e0c2fd6958df3262 |
|
BLAKE2b-256 | 1d153b7c72a3a05908e8920e2ac81b023d1fa6a7ace3dfce61e076defa51b6ca |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6bac2db45da454d153779f0a2182da6a0529da9d62a35a93dcfd22325940500 |
|
MD5 | 576d5a87c88f3894c999904462361c7b |
|
BLAKE2b-256 | fec750c499d668d7c4b843a69b0f6cc279215e54bc48bf83fd221a0695cc7126 |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 276f283f5f25eac7bda2e2f5c1798199f5e8ab75f2e3f63f340cf9757a254486 |
|
MD5 | 741a4c9452432695a66c974c5c52d771 |
|
BLAKE2b-256 | 8fb507ce1e2d3bc5fdb2ff0470c55b715d5bdd72951b4eb917b339eb1867e123 |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1e3e2829970c4463aa4e4e464a51655c1255c24fa6f3edb1c108032b4e57770c |
|
MD5 | 7171e63c1f9a24633fecd8fca6834b62 |
|
BLAKE2b-256 | 91a274d32471db963daaa0ab0c9c7c4a07dda79ae1f7288c610f91986724e493 |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be9aab2b7438fc39645c19355abbf825afd4c1735a2c68c06896e57bd36d1df7 |
|
MD5 | e054b5ece8bf4c8a191a210de1f8e5e5 |
|
BLAKE2b-256 | 7edefc67dada9c59d1cbcb7c2504f5886eeb42a48ec881d426cbfc591c6ecb46 |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9f581e13ccdef2de06b486c041461d0e8f07821703085d389b7369afae408a7 |
|
MD5 | cab6f2ad87511c69169b6f505f32c4d4 |
|
BLAKE2b-256 | ea348dbf51f760feca19fab2cdf2f3cf01d906c75cc2cd55a99864e4a6388be9 |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f65f37c571591e9cf2c616102c8da9a8ba1640b4fc1b8a5f39fb106e7eceadb7 |
|
MD5 | 798a9045a4b743b45ffc8e158d0a5eb9 |
|
BLAKE2b-256 | 532c002dac32c060df95a1507b02b3fd58e7c95c129ee436ebf5dddcd79530bf |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3adcb64f0e52bd926a4e8761ff6d78a9031081ba50e02be4057a294729835d4 |
|
MD5 | bf61027c9bdc2809a65420b86e2aea87 |
|
BLAKE2b-256 | 958de2d4192cda710e07ce9754cfac61d180652e25f152ff955510ad36fea4cf |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c53137182b8b7514d2127073c1a425040411ec2f86d27ac16863ab01f42703c |
|
MD5 | 4926ab1e075b6c6faeed56d891cfd84a |
|
BLAKE2b-256 | 257317f8a48a38ac04f43560277eff78641693c97f07964cc3d161aa3d5890e2 |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e6c53078c46f2bcaa4af80d528366490717dd6367b347df1e8cdef078e7335f |
|
MD5 | 0e70432ad9bc2dd92b90a114c15d01fc |
|
BLAKE2b-256 | 662527b94ef10f6f40774e7efb80196868efe5c1cc3769e79ec4e65dac6231dd |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5454688cf1e6b67f4e09c4b8f6560196ee138d6ccb930ab06409e576d589cd8b |
|
MD5 | bbfaf12a1788ab7c473d3e0fc7102228 |
|
BLAKE2b-256 | 4dfdc23607eec05ec68277bf2e7aa951864345b6a7fab0a29465f6eb41a7ee89 |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49aacfb543540941c298567d028d70e452a4cab34b7ee9bccee945f979f22d4e |
|
MD5 | 8535e7e03edc74da3440f2de8d4ca8ee |
|
BLAKE2b-256 | 210c009aa2621ca483ae232ac0f0ccb2fcdb2ad66d2fa8643120032754a8cfed |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c62aa1a01cbc81d5e418d0c7504d6170b60b9a4a19a580160c3a894eb58b3ff |
|
MD5 | 80f13b6fef4f554f74e3ade68fdd2041 |
|
BLAKE2b-256 | 190caad844dec3075c21689725954cdf4c74727f60f41f52030cdde642f502bb |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e8f7cd66325d9e2faddedd8c68cf48d62fd28b36b1fa8c3077579b1e3f070bdf |
|
MD5 | 112f01ff10e8ca97265f643d67bb4475 |
|
BLAKE2b-256 | 8d0051f39baea9ac8517e2dd6e91b39734232173ae0c0fe16206e19623317de4 |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8c116eb03e5d02f45293f6cbb71b859cfc32a43a7bc011a0d93575074480148 |
|
MD5 | 4bf927ae0052fe15eab9ed9860a23fdb |
|
BLAKE2b-256 | be6100559ae019a60f3305464bea9f03a0e01471ba524aae879c8245c7398ff1 |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d09e9da8467ec55faa7368e38ec79ea39c0835216c6f28a860d8cb5c3930caa |
|
MD5 | f4220e1068a20d21bea9bfbfa9beab43 |
|
BLAKE2b-256 | 0290875b2848b34a26389d70e82fa75b4087d6117d2ac3b58359d79572578373 |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 87558c55c0fb86405f70aec519ced35d927e3d562e63492f71a304dce7787d15 |
|
MD5 | 7f003c150c12667e0b4f299378cdd7e6 |
|
BLAKE2b-256 | baba091db725457e74f18d7ac8f50183f574e1c93d01371a22523d60512b351f |
Hashes for pyAgrum_nightly-1.17.0.dev202410231729615378-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f1016d061a7dc7fd91aa435204e118e069a10f1b365ad4df9486a586bd1ab86a |
|
MD5 | 2187160f8393496440826c98b6c61ed6 |
|
BLAKE2b-256 | 0869474985e4a57ae2de1574560ce7d84eee985b5822da3c075d6c1cb346157f |