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.dev202408191723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f4ab073194dd25ad71faa1dfbec0feee1c0b274c48d7c4408b8204cb4bb3bbe |
|
MD5 | 87906d203f48b8d01e2a16c2b58392c7 |
|
BLAKE2b-256 | ebdd3aae8ab52330d5c8117077f1e765f0229bcec2161a8a460dfe80cb914541 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bad086253018a2b506586a46749091456e88c94ec9a2abda8b13f1a3ea0aa4c5 |
|
MD5 | 72b6f2273fd882032f11026ad904b33e |
|
BLAKE2b-256 | e1c65667188b4dd8e172186c869d6fff3ff26036ac6fee67cfaac3a4b44dd199 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3f8663f7403a29d0ab23b9dc76a426a19f682e79a36cbc5e82ecb113e3c3b6e5 |
|
MD5 | 2a33c4ceeb798585262779898f319f96 |
|
BLAKE2b-256 | 740bf97a3705dc6f17a16facd88e7b248fbeda7208795fb15277edc5975e4ef4 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e731c13bd5d60238d83ee9667afe303f1185f0ba6d67df07c181ea3d6d683bba |
|
MD5 | 8d6e1090f055ff483662a0dc69efec62 |
|
BLAKE2b-256 | 4cf9905025694a9b9dac6e28b7a3c327156cba94fe3db802bedb78b37b662482 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2bdf96a1a3d86671b1519219a69d97a95e7feb6439851edf90eaa9560a77a1a5 |
|
MD5 | ff7943132249d877cbc6ded04724a125 |
|
BLAKE2b-256 | 1ff23077df13c5cc487ffc9b27f7ca16bce7c6418220438de60a7c8cae3ca91a |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ece4bdc487b67b150c1a43865929e4623be807eed302003db3bfd9eb4b1fe41 |
|
MD5 | 9a4d1f201f45bbc69a6909a383688eeb |
|
BLAKE2b-256 | 758ec9f3f386c8f478073b0758925ad0f740f71940a69a14be8a93e75696dd34 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc929c248adfeb886551cf0a88c47faff08b47da3d9b924f1e6ca1615657ea66 |
|
MD5 | 05f2edbc74ea6afab4ff069935c1eef6 |
|
BLAKE2b-256 | 347a1dd8e3289b85b27c9870dfada86e8fcaa65099c09ec858818d85ba28b7f9 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c1b8ab063ab8d27440fde98ccdd57043127bd55171f42f209757e65f84371a2 |
|
MD5 | 8f799af9faa06506ce402e412991d1dd |
|
BLAKE2b-256 | b050a05be6e8c8c6b00e042ee5498068e55473b19862286bb18eb01cf1197b13 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e319efa50b231b1815ec3675046e1c4d7c4b734aa05242fc9600ad676b2afc8f |
|
MD5 | be5266be87c276ba1ebc6d9fdf4c6af9 |
|
BLAKE2b-256 | 74540b11c82d751318dc231fc1d9c9d0744caa1fb69941af94bfc0420b690978 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f4f60ef17aa8342937a81f1f155fb468f12a6021c92b212f9fed8fb23177a7b |
|
MD5 | 586e44ef9c7052668f84d2535ee08ef9 |
|
BLAKE2b-256 | f9206af3c2452acc5e6ff6a67334764eb13ae2280adca36fbade651f4cf29e1e |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 697753243f570aa880026b47adbc317b1e551e74e5d78288eaed32aa1c3f4048 |
|
MD5 | c8637487ee15975c3221c545e290bc00 |
|
BLAKE2b-256 | 4b16b3c1cf72e7a11cd43e758e2a29c9a23e7913709b0fe3c36d8a06bb99b462 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 796dde37fca1098ae77cf33b7c27160efcae5281f0d6ab00ac2adb342793e6e1 |
|
MD5 | de6ad211f76fc00e842c62f71acb1acb |
|
BLAKE2b-256 | 80cdbcc94386761828f1278efc1c252bbd215a2d152c2c10c201760995bd045d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af252584c5047f5435619f6c6ec08f362ae20cc10553526e7b217ff9330f9afb |
|
MD5 | 1852bbc8dba32aa3f73c33a861362aba |
|
BLAKE2b-256 | c1528201b69e7ebc181dbe22370c4e4172fac505a087daa76d8e20192fb9b8f7 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5be2d99a9bb04437054736f062bb7a1472e915037b6cc886365122b4df0bc954 |
|
MD5 | 09a8da9140033f26d4c94a10b181ef15 |
|
BLAKE2b-256 | 89639a4f58ab8ae20468bbd3090f7eb5e06348f302d26e255d49efada2e3a3c1 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 787cf44032efa67439e3583dfc2a2ddd9fe9664b83bc9ee8c0ccdf365ee83487 |
|
MD5 | 6593cd47d8c771fe405b16c62f8dbf33 |
|
BLAKE2b-256 | 976f810ac78672c1c96d96c9200f94df29932764c0f0e26ad7f8e7a3d46bedc7 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b95ea1b4da23c6895a3719bf813ca71e44fa3395ba99e19b4fad8bd8e8b3a0c |
|
MD5 | 2835e8dd153243d39a786f3909da5221 |
|
BLAKE2b-256 | e31afcbb153fc1e98ea69ed9a709a8f7bae487c17697c6615928788e943d7817 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f83944f52a325145de1de81e47508c9ed3e275fc1cc87912822c84a0eff471c |
|
MD5 | d0bc2e6cce745dab828722d0f225838e |
|
BLAKE2b-256 | 7490ef69e9ca7fff34db5e16e16cb08d3841843d48dbdbb11c7605394ddf820b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e91a6c7a8166c8d88a3e646025fa07ccc89fefc2fda00b374929f021ffe8a3c7 |
|
MD5 | 0fd5a769863ce878b7cfa66502892c37 |
|
BLAKE2b-256 | 968554d32253956f5d306af36b7ddfde6a79fe397a04e6e942aa1a25b83d83ac |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50ee2d01cc389669f281c5d9920b028e82668b0ea8c208d8c5bc1274e341d5cf |
|
MD5 | 00c10d5891dd9492196558d839424ead |
|
BLAKE2b-256 | e311c02a09b5f14578f06198279e2fbb2eb7696c406ddefd88c9a8d6b070ce06 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408191723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13951fcbc89cccd11f3129b953a633cd4feb33ead995318f278c17015003e0a5 |
|
MD5 | 95c783869b6d084ead0a05a8ac546f8a |
|
BLAKE2b-256 | 6f397e5cd1aa61066d9df957444bd40a5e898bddc74ec5775c5c86e28fd6abed |