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.dev202408241723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fc6a7e77e8cbcbfc08980434bae0643bca7784032a03dfbd3dfa80eab4a014e4 |
|
MD5 | 194df8d53136263934f2b57b94913f96 |
|
BLAKE2b-256 | 8240a0b40860ff7a2b5aafaccda2331d2e627274bf1764dec0f2f1e589a38fa0 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34e4fc84ebd70763e72d84cd506ec21d6c2357c55fe33a5605321e26296d51c5 |
|
MD5 | fe770bb8d2041ec542de52ec6b684053 |
|
BLAKE2b-256 | 1115612669611f24b32f1ee089271e3c06642a95d24a78ab727651ef0685f6c5 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 293bbac256662e15860fec1b4804a83be2991a8cc6ad7d5a61046646dd97ff8d |
|
MD5 | 7ee736e689271a013d116dd7f22cb78c |
|
BLAKE2b-256 | dd7b865ec7b19554c7f5ec3df0030bf2c049de0ee12fb09b916896269fb9e8a6 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 19e75fcb7361d8020bd1ca3e191510453157bfcaed1200a2108cde157cfea2a4 |
|
MD5 | d0c80e9efd5075fce07d64fb0d670669 |
|
BLAKE2b-256 | 71656ce848c800b13089de7f603400ad3945cb8db56989bd4258b984f4c4a1d2 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4820ea3c4e85bfc3102ba28dbec69d63b30639e6f64509e71a062db030de0023 |
|
MD5 | ec3e35db1a3add55aef26b408e504df9 |
|
BLAKE2b-256 | 6ed1c4367407972f36f85dfd255da81f5d63899d49524bddfde2a7aff63f43da |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 824ca5f1c57f369d4b34d1f40678598d12b52a88c242948dd89823e192a500c4 |
|
MD5 | 4348079ccbc65028b65741f473d23dbe |
|
BLAKE2b-256 | 7140b8555485dd921be93ca7c20fe0e8e30b556a7d61984455601c9ea9aef8c6 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b4908bca0722ce50020b7f6d59c04ea13a2c7523c11245d8694d041dd35434a5 |
|
MD5 | a424911e7d3c11d83cf4f9434287def3 |
|
BLAKE2b-256 | b3ec2d3f4f930d9652028c960b47a2b51a826941d7c63aa0ba23d526ff470eb8 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 17817211b74cb1937195da45493bb38b769b8fa1df8b45fad773cbacc641bce7 |
|
MD5 | 5c14aa16689e34398f1a38af347eed99 |
|
BLAKE2b-256 | d60169993acc4b6de4a4f1909fb93bd5bb7e93d67b314e8829a80843e5dbf7c0 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d5884fd15b3ce077a0c1a4bd2536ca5f29b1054a0f593dcf408aa3d21cd6838 |
|
MD5 | 498f54992641538df416a1ed82767d78 |
|
BLAKE2b-256 | 3cc117aee7b13e7938a95ce194f717321c90eaf4695c53bbd71821e05b523443 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d5f04cfa6f1c33eb1a6165625ab1f276d64d711bd3c21f5036933171bb58ca8 |
|
MD5 | f760eed0e4408f7b3cc1433d1faa053b |
|
BLAKE2b-256 | 9d0d0704caae253a32890cd6242a555dc18326062c6eeaeab29de4459e7323a6 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dd933381419c5c44139e7bc2727d680e23a26eb00c1cdbdcc59676167095ddb |
|
MD5 | 2c9641537e921a87ea2463f4fba4c8ea |
|
BLAKE2b-256 | dbb3d09d9bc0f7c88b77f1788582c61375c44ab62c286efa741bb48f8e6556ef |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53c97482303d19ba4dccbd5eb6ef293ca92e35527fc4a7ce0c9758a76c00b963 |
|
MD5 | 60e77e8ddc109dfcfe7d14e050989bc3 |
|
BLAKE2b-256 | 555c6127b7ddcd507edd5d4e4ffc8ecef6037c4f9aa46910590c8239e4a0d584 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21ff9bb743f6b328bf1b362a99c6ed1c577b765f678fb94d7288d0eca036c188 |
|
MD5 | b9edb4f8f40bbbe0604f1b01296e00fd |
|
BLAKE2b-256 | 1764addf723020780d5b3725959cb484be01b7d52a869ccb17cc88580391aac2 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d55c298d6d77633aa25a500253dd9648673267674ec0dbb7037a746b34a835f9 |
|
MD5 | d56d8b8f79627646d5a2ae7d9af414e2 |
|
BLAKE2b-256 | 8edb08df2e8c2d73e8659e5defd2e980492482026553fe86853c0f818b98f82d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b60a7b6596bdcc82a5f20223e0d8b0d114b9fe94a30eb9ac1a3692c738f075c9 |
|
MD5 | 8fe4600a83f5bba65e1ba989febb1d63 |
|
BLAKE2b-256 | 985d352ef2842f57df633cc511f36b011b3dc510d217f80f009f6541c318b427 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4832ffac11589d725a1e86d4e4539d34b0229756c92930765ec8e33939bdd627 |
|
MD5 | 9e1daa9c9b1c6b0319a9fb48d033017e |
|
BLAKE2b-256 | c01b23ecbc1cbd4e38d10334510e3e7cc694dae2a2e3d8aaa79a6dbccf898025 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5723f1cbbf7e2edbe818235601473da78f9d6084707533616ab0a70cc1e8114c |
|
MD5 | a2d9d0df57b1fd9c09ac820b85675c66 |
|
BLAKE2b-256 | b37fca6b673bfefd04d749668a2e453d584efc2f50e631e054fbf709d847be5c |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89ed5ccc843bc72620796f0aee5e05e0db70310fdf20390055c258f6bfaa1898 |
|
MD5 | 6157f675064273ef6b2edc376ff6edee |
|
BLAKE2b-256 | 4641185039f21a7e1717f190b395a962976bd1f566401b3b597b8b7732160369 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdeb6b4d163261b6a33d019902afe3a4db87d9ebf7acedc0a439c619103f9b2b |
|
MD5 | c2a95c3e47f2afa08e86cff6ba2ab95c |
|
BLAKE2b-256 | e23514cc8ae5b7e962361e53398098c4398ae91cd9bd86126aea6dd31bf6dd71 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408241723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c53b6a736fa7fba3ed08f66291a3d042c180b2170c2fdea994de28219c9444f0 |
|
MD5 | ade6b3aec563155ca339989f26640662 |
|
BLAKE2b-256 | 7ef6c1d43092256516348cc72abd6c168a21a9bf6edbabbfd7b54191931e1538 |