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.dev202408291723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 99b965db478a618e34d1fc5fb21567ded384e56da4f9de4917427fba3ac82cd2 |
|
MD5 | c777e24c72d41cf381b3ddd2f91d910c |
|
BLAKE2b-256 | 39c890e6a331d6c5b8cfa6fd37acb52e536a65426567f860df318c7de2473060 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e83a8af047f944e9a6921fb0f521c580a9ec533fecbd6ca2c44b644d5ba9047 |
|
MD5 | e096becae1f8ce55cee2292a96975bc2 |
|
BLAKE2b-256 | 73cdfb3edc68d51cbd3d9be7c2d8af1f8dad0a2660ca601f067e78ceea1c3010 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32b2e16a706bcacf15d97c78baee68b266af91136697e80b1d5cfd5b379fedec |
|
MD5 | fa8e50812d52f10082d46074f39ef78e |
|
BLAKE2b-256 | a2e0517804f5da86e1a2e12fc2f167d0e044f75fae1c104bedee09573c03d6ac |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 561b8aaf30bc3f1441418fca61b6ff94db5b9c7aed3128a3a2c3b356ac4f96d9 |
|
MD5 | 56cdfd5f6c077d20a106b60c6a9f9889 |
|
BLAKE2b-256 | bc50fcce93f771631969e418793b76bdbd5ed095e50a64888fe36d9a480adb94 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10a6d57d07cba538821c9f5243d448b0bec6d4b26c6e78094790f80eac40030e |
|
MD5 | 044c839f37a93387ee91f461000c1a3a |
|
BLAKE2b-256 | 635b2ebee838c7913b6c12dc5feaa250d8a6f2c258121ec52fd10c6ac6ff608c |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 226d4d84ac7851104221d01cfea3ab713027a8469907da148ed4221f43159447 |
|
MD5 | 8c21b0d26245df316b1174929b89e8c4 |
|
BLAKE2b-256 | e6f92d249e6c6707a5d89e3978c946dd2fdd2dc0d340f5679e40f9b88b1a25b1 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 726b7270ff0f2adcf6a5bd550bef662c94a250c95731185fba45912c00b7a502 |
|
MD5 | d20be2d17392593fc41ef62f6de31d9d |
|
BLAKE2b-256 | a2293cfb60f238e40e773d05641af1699500577a6efe1fd90a413d489052f310 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c86c0c88035a8f516bac313c07108950cd77a4bff3d3103ec7e7f43fb815b955 |
|
MD5 | 241004b066ec8f49f921f69c5115eff1 |
|
BLAKE2b-256 | 8448db4b159636790ad1d982a9fb3bcd745426d8faa23d5aa4731d3ff0d0c74c |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71fe3c3b487115b682c6af45abc95f84495fafd23ceab76ea9faeb158f2d835d |
|
MD5 | 40529e8304bd9be58b92b7d92a9e7e61 |
|
BLAKE2b-256 | 8811de5194fcbb2c95f500cbbacc9064ec5170b4ba2f742f3cf366c76bf8aa49 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d425dd009718ff2b0da2971154fb1fb34892c7f4b3a844d8360252991cba3bd7 |
|
MD5 | 173e381283fcdb9282a27952c3eb41aa |
|
BLAKE2b-256 | 16cd342a0530e8410ce30d657c01351554d6e3ec035584a8624bbbb92a3b42d5 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e270216343a3cd67a174e74ff3cf12e289119fd00f18147d2d183461085ec09 |
|
MD5 | 59b9896d7ecb2e90208bb2d3d8dcaee5 |
|
BLAKE2b-256 | 8ad0b4a72a0b86ab3fb45f5029a2bce6c8dcd27b6b7d999186ef37f7302cedd4 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea4266f152a37dc671e9be6db4a393417a0ce92ecb5abd4a9fad49e298d88baa |
|
MD5 | be03fde4a1cc2f82eb42db52a5fc19aa |
|
BLAKE2b-256 | 757e6eaf68b2227f2c1d45f8f500ecbd278d1ea45666618d8fba310f1e650498 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5293b500e331e27dbe39bcb462cee6f18014346158295c9de276694514f5408a |
|
MD5 | b71448e4c13e2bc2d18805aba33236a9 |
|
BLAKE2b-256 | a8054aa7589abf65298ec12a526484ef3634d73326769cfc1047ff84b72b9f71 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c9e52b835e8251b2e6a76ec16cf23facb8d1d4446fcdfc1fadd4f1be713398f |
|
MD5 | 9454c405d527f3644fc68aa5e63bcf7d |
|
BLAKE2b-256 | 2ce4a6bff2014053cf3217df66a4f31aaa46d0796ad166d12f961f2ac0bec69a |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8713e43f6c421ebaad089e612a16a0a8207457fa73d4f82a92fa22de61f1752d |
|
MD5 | 225348bd05fa28e580c5645a2a3e6846 |
|
BLAKE2b-256 | 5e43af406bce22e090e3cbc272207d30ca8a3fdb7f869ebd9d88867ee3606b19 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d33576e450876947dfff4bccd2507ca08c4b4fa673de9be5685b4359116c6f4 |
|
MD5 | 10209de72a44120324a3fefaf837d28d |
|
BLAKE2b-256 | ed7a515a4d97dbdea1c4e8bd11df66bbe8022a14833deb0adf2d05d4e2d075af |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca4ccd9dcb25613ffbfa8f29320d0ae1ef6003d354c7f23f587bade002ccef0a |
|
MD5 | 64f5de94fb5a21de1d5c180be03c415a |
|
BLAKE2b-256 | fd0d6661fd9afaad66597f99e45f5c352549f70b7056db63ca984a92fbdc69f2 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 058c2d1e3235302dc7f556d4137e2ba7b5beba209a785b291088958cc529ab28 |
|
MD5 | 839f4306f1283aa7e79e16d5b955c690 |
|
BLAKE2b-256 | bce4a1b4eed4542498e31c00833325d86947dc9e40c0bd3c9aa81bef67553d2b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8a9a6e913aba146a6d66a6cf2cd1466c733ca834c8464ac76af3759e831aa7d |
|
MD5 | 2486da48f190cd2f390ce9a2d525380c |
|
BLAKE2b-256 | 046619eedbf99250bd6159ceae5ff9154a6b15cc89cedc67ed46b57ff1e4e95e |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408291723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7619d2235e3dafdd697f87ac1e59d26fb0ddb0be69b6f1c10db0bf87c5379e04 |
|
MD5 | 756c0adde0baa19ac9f0904b5e7d0143 |
|
BLAKE2b-256 | 5f4bb6247e28cb9dc2b68054c672f418acd4c5e792de4537ef37dfaafdfb4966 |