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.dev202407291721169663-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cce215260c9dee8ccd81ffb8ead7c5c8f7726d6e88a9efe42e111fabef9629c7 |
|
MD5 | c7ed7b4a60e89b4ac875aae1a13644d1 |
|
BLAKE2b-256 | f10bbe342fe56e698ee1a992696e4a073295dc0befc717543b13515a97f4466a |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35a25d69d61487d0bdb89803df65a0fa834bc892136914285263e248176e9f6e |
|
MD5 | f5c1be2f39b6ad626b55e6d1b1c81547 |
|
BLAKE2b-256 | 087258d8013ded07317f82e0bd7bfe2849c80cf12d0ea962a4f61a46a49f92a0 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f6d3f30a2aeb8b87371f0e310734d298fd410230bbcce6c0ad0671508690d2a |
|
MD5 | d4738b08f6aef6c321c76fb3f7f8d431 |
|
BLAKE2b-256 | b85866b803759edaf4dc9dcd7131ce75f18a80742d1829bfa68013c62324600a |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f788e88a6d9aba3fe61ba283cd92851a63808139de805ce10da33ee2e3192d5 |
|
MD5 | 2a8bf2891ef106335869a4ee3a33a07a |
|
BLAKE2b-256 | d93b8e9bb72deb1abe7a0f4f1e7dfe5df798c141feb567d128ac55c3ec7bf1ce |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0f92903a68e0194b80a57c42d9e47e5270da0d77e0bb1e09a42142016cb22a0 |
|
MD5 | a70c696ea352543c3031e1cc600bab23 |
|
BLAKE2b-256 | a1a7d1cfb3cb6f83abd94317bf02a6e18862b9392daa88e08a64b8f3a104834c |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 699f8b27e5a17675e57f7943dca1630646624be29f55908879472a9bd69833d2 |
|
MD5 | decf00b847c012c0b54777cfbc7bb420 |
|
BLAKE2b-256 | 91501912dc40eea53b2fb7e184ab8b6a85eeb67443db1dea33d9a833f4d3f6bc |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b4e18df47e79f0cf839a07209f3492ae71d3ebfb99b4bd116e5c1354d25b50c |
|
MD5 | 1f66dd945dc59a4bf4d5fe9f6e28f973 |
|
BLAKE2b-256 | cf0161ff71411d9d26a278500f107043ed00304734b2cd69ef7be55b4f671d12 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f13fb360496cdd792e137ee27ae7edd12c5fbfa5b3c9c7afdde02ddeb38cdf1 |
|
MD5 | 6e1e16cbf6ccfe75e667bee983b6c70b |
|
BLAKE2b-256 | 2b601caf23b10339c371aab42492f3463514f5d1c3fb9273583b9eec05da2090 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76701f9ba4aae8c8e0f8b50d3d14603e1e996f8b32a23d355a0f2be1dcbac534 |
|
MD5 | 7743c9a9735f6ec48c94de2211269efe |
|
BLAKE2b-256 | a433bb3f522bec01b4a31861612d95be93483ec5e6952d8dfc324757a9986d0e |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac2e634e8ee461d2f1a47af5545b8a609141dd5e8b231837342d062c5506f4ef |
|
MD5 | 8489ce11db70362568c0cdb872ba8dd3 |
|
BLAKE2b-256 | 3f26f879733711a09e327386ef70f1a71c3d267201b2dc3b873d272a37ab8bbb |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58ce9ad0f5752dcc94d2bf077bb09bd00e366abd76c4af674ddc42de80dad4ec |
|
MD5 | dcdb944be968b2fba063be775a8a6ab4 |
|
BLAKE2b-256 | 6922ab3ba1dd94d922198087c5cccf1be3062e8dea772e576d2e197772d10618 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | edae01f3ff544feadfd997af1a2e39b74fd62ba3a2bef81149d1378347df3ee6 |
|
MD5 | b0fe20f0b17f400dc7c66fc91f6f0802 |
|
BLAKE2b-256 | 4c4299f6f523c5d90c750858d22877202afa3c44cc55a2804995c9f020420320 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d897a4a5f7555f181035c25ac498a664ccbb2edb511883c371fdd433625d2a5e |
|
MD5 | 8fa673e64b45563959aa86c342c2d0cd |
|
BLAKE2b-256 | 0730df208fa1669fc7e403cd4ae8c4cdbf1666fd47b9ebf28c978862df44ef92 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45d84b0cbf39689d6f3a591ece801d55cfded4c90ac21639611ada2c7dcf264a |
|
MD5 | 521a3ace96e59b1e33cc1ed15699b85e |
|
BLAKE2b-256 | bdcc56248a070a1e4ce3429fbba34db1942c62d12d5867f6b474805b162ef4ce |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af968b4d8182f72c364c2e9b54b7e67f2be9f03b8ccd2a294516a6e666972c9d |
|
MD5 | 77e3a96853887723575b55748cb45fe7 |
|
BLAKE2b-256 | fc51e46541244ebdb321a11de48bd58f15d1960b0de128debaf955322a41119f |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b78add5c6428ed0c1039c9de572779c180c8b5330390df1f3eb7f1097f802a72 |
|
MD5 | f96aa9eddf2af1bad73d6a29f94e9dd8 |
|
BLAKE2b-256 | 195e3b4cd024ad1ebbbb8c9e870631d62f79cc01d17743814087fc400fcc0455 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3159705dbfb129967bea986aeec51d341a78ab0f6c64f4ae2f22e6bc7f375e38 |
|
MD5 | dbd266c0eac5bb4d5095433dc85ac358 |
|
BLAKE2b-256 | 6c72b34fb5c68d961682cd5d87f06dad6b3005dee5cbe407e599adcd63c8bf40 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5f9017943debe9354f4ae0612dc7cd36676d55d3bd8f43c447b3e65bd440bca |
|
MD5 | 891a5745d4a8c9ae4176891ad52d897a |
|
BLAKE2b-256 | 3b84ebea95aba0c324194c5000a6dcea30c42c3dd9f13836c5f8ca1cb15a087b |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7704a218637ad09d72cfb21afee4ccfc8bb84f3db2825dda8b986ec285ea1be7 |
|
MD5 | b5cdbaeaf3dcc6d80ae45bab2bfc3059 |
|
BLAKE2b-256 | 5b131cdf96fee93ec3a52dc7019e6d0d6a909ebd265e45736158366190cc40cc |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407291721169663-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9b1fd6c08c9caf3dfbe855f0c59eea41566c76ca6c3a367a57848895eb376e3 |
|
MD5 | 4075b7930e2f10dab0a6a9ca8d4d12ed |
|
BLAKE2b-256 | 597bb2291b46e48ca54286f316614d8cff975ee4bea3a0df7ba7d90770399cb4 |