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.dev202408261723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ef5826068cc85815ba784a4eba9bf262044d2c2e88002757a7ffdc7776eca0c |
|
MD5 | ea23c9eddc7e783a5dbc29e6b36347c4 |
|
BLAKE2b-256 | ddf1f40281ae075fe60f6acaa22545cd8d0eb61b4fe4c66f5d24d4aa71830940 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf67b7eb2cb25eb93d903e46f7711a96b179e19f7aa1f10544c2f0246cb3c69a |
|
MD5 | 9df90948aab105f0ee2dff2865ce8402 |
|
BLAKE2b-256 | d808f756673cd1048d0820433594be9dc3ccfcda7a00e5e85dcb183669f0e05a |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ad5565a6e103d64eddee18a7844b9186e06becc0ff1c6a2f36e1c7628397e74 |
|
MD5 | f50e9548d6199262e17a814168338049 |
|
BLAKE2b-256 | d329723fcb5fd0a53bdbcbb5cbf8fdce7ebb89fda83020a0c90296fd0f0f0c76 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8e9c84ea970b2be6879ecb1e700d9ec5fa15b0002a4992a590d9f28e9e29323 |
|
MD5 | e5c9436b6ee18a5e7b4b6488e295f8fb |
|
BLAKE2b-256 | 8852f1df1bbda553889feed92d4f620daff6448c07e1920eae01db682176582f |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7dfa8c45c315984a9020c74b6609ba87d9cd7b1c7e8208636750dde2462e07d |
|
MD5 | 866f06dd3b3cdc8a104f157b77cb6cdc |
|
BLAKE2b-256 | 5193e6e6bce906740057e44b0480d6fa34f79c5515dcfe4019b49149e2dd0940 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee120df775ac46c5ae1ce8f972348baf715386e11f418a078d4ea4591b5382db |
|
MD5 | 4fac9555f12a7556277153840fc5b6b6 |
|
BLAKE2b-256 | b411ae5ac4bb78d4a75f2ea4e23888a26538027e995a2ea38e06702e946a500a |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5aa04f2a90befe29b2d740d409474ee01b2d8dd186f908a401d2f042bb0784d9 |
|
MD5 | 5845ab069b0378f9fbf3e7f158709c08 |
|
BLAKE2b-256 | b6b4a54cc842943c6d5ec284057a25f1b9e6116a1ddefeb541e8b30f02b1c2a8 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4e026e43b32cc8fccd8021cce238659e27033800e17a8ce970286e48c1c7b5bb |
|
MD5 | cd74bc1a886de137dc713212d0dd4bbf |
|
BLAKE2b-256 | 5dcd943fc32b8c753428860d194a8ea69d4ac2d5ab4d945c02113accbb4c3b3b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41c6fac2c12ab9106f31c70fb4a855e9e784f6c6e75f7d9d12a24327c758b52a |
|
MD5 | 84799d3c50ae60bc1a344d77e177134a |
|
BLAKE2b-256 | a37c57eb5a168750ff1bb4e2684c2ab5549e546ecb45cea77bddec6d429e909c |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3054e82d153d94eb6a4be52d808f40b9e623c860e3d9a7801ff36244d2cc7825 |
|
MD5 | 646de11e4dabee403709b57bcb7d6da2 |
|
BLAKE2b-256 | cca210e0d9592d3b9e565f2186b14f1fae3ad421d1cb994382faee039d8bafc5 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d969d2e2c48d1b538afee269092fc3cf32443f23ea4a59b52140e5231f8d1ab7 |
|
MD5 | 0080429bb804ce660d96be82cbcc5bea |
|
BLAKE2b-256 | 01c0226224d644aa356f7783977a3fb11650ef5938c7469261b5456f2aa1e9cb |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad7ad3e8c8632c6b50c2ba6eaee99587486d92b658a8ed53bfa7daca2713839f |
|
MD5 | 20a3a3932c7534b9d8486adb505dbbc2 |
|
BLAKE2b-256 | 4e4987a2bc3c7c058fbf6806120c71c3645494b0a9e8345569ba811a6fb80d0a |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c047dacd177c77726432b6feaf2dcd47fdaf1985fa561473edab308dbec3193 |
|
MD5 | 72287d4ffc38386cb50ac1a6ba134daf |
|
BLAKE2b-256 | c6fc3742641ce56e395fbb2c77ef0693cc1e472bc1aba24a17018b4e62d8bd7f |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ff93fed4ab651a797086fba297ac38c03ff389002b119ec2bfeeac57110a014 |
|
MD5 | 4da30bafd7c2320dde559444ce5d8759 |
|
BLAKE2b-256 | b9b33ba7ab94e061660832c53220e236098ec5fc440af19a3a6887aaff563ef2 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3cbbdfa69cf2fe79aabccdf64cd8e4305fe9cbfd265343987d0aa123e702b57 |
|
MD5 | 36d748642b9715dc4b395c09b233a33a |
|
BLAKE2b-256 | 8f58df4e0c0d1bb2a9ca5db3919566a61aedb9a129606948c72f7b5c3ee46cd5 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 613f56672f7b847951fa3f673d696e66ed753fd77a04386eee47bda6e749bd45 |
|
MD5 | 31fd1954b881bcd80a1f38f07d371030 |
|
BLAKE2b-256 | f72f6809619a32c7b2fbb1a46076fab8d62984d6a86dc64501e110462f7b3072 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a490bc279f169ee039e71a0ed93dfa3915d81d5140747104c6850e5782a36f9d |
|
MD5 | 3e6c0228c05201b897bd981983ce0add |
|
BLAKE2b-256 | 44213c4866f9fbced4afe8567c7dc86f1b7422fa502dc48ac8bce6d5b488edc0 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9eda5bc373ec7364b763287eb6419cf16a9fd16ff77ca4205a366b9689c1d724 |
|
MD5 | 5aa621c427b0d673cd4039f59baaddb0 |
|
BLAKE2b-256 | 51f7a9b18732da66001835b7991ab8f0902f7aca0a5b8dfed83dd1c0267eb312 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82e81d16503ce428cca9bfdb042e9a82c325215933ab2ca613818c9d83206660 |
|
MD5 | 5b2314bbe93e6008bc9a4ecadc86a1f5 |
|
BLAKE2b-256 | 6740e43eeb4796a3b8933141825ed00e2af7268c5482fe551fce22b145d95e90 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408261723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 492e773ac2160a43b3ba8a2e43fcf4ab440e61df0e5ca39d66261104cbf7698d |
|
MD5 | 1b0c96695f385b7ebc0423e422b95c74 |
|
BLAKE2b-256 | dd1ce480b1056758a1c330362370b8ccb8ae340c2f9343e077dc7172654cb5b6 |