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.dev202409091723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b97f88c8280c2039706121abfc9b25d0841f6126ca6123b8085f0a0305ad3e4c |
|
MD5 | 2bd5d9722694960cf5c3c4b8316c0fe5 |
|
BLAKE2b-256 | 26afbc20e687d71ef734038a1c40f3591f18162d3b77cbe44cf5e50b53f76040 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ed62502b4a1350cd2204be9aabfa54824f545aca9dd3d1f86525749e77fcc1b |
|
MD5 | fdcfbaa8c1b9877295d0bf3d716be8b8 |
|
BLAKE2b-256 | a32a5a455aac8525bb9a868ca4919f65f4ece97659ad79c6d42d61196b5099e3 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49ea474788d8215408faca48cd5f6b577467a3c75c09a6a8d72b81b4f6f9408e |
|
MD5 | fa03a8944d88fc08d1d9bb3d7474c9e0 |
|
BLAKE2b-256 | 162b330626fe3207cf6c8d1e7420e614a635edb3d8299cd8577f649c7f55a8d1 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43100815aa5b04a404422be4650c357a396267f5e5ff23b26afc2a5e6fc3cbbe |
|
MD5 | 03ae13d04f5587d75a7d017b02fe44f4 |
|
BLAKE2b-256 | e49e7bce4f26fe2d39419534a17e59e6d3dd722073b5bf6a2f234b4e625bd8ec |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0de984b6f586086104f03d44d48cef72bb5d7abeb03e9ffd4483f199ed87e2d7 |
|
MD5 | ff69d56473536e8b3b5bec58f008c7cf |
|
BLAKE2b-256 | 4dc4066578d6958aaa7c04510c91fff770bbd399c21c968fcd3db0846a089ba5 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85e2fbff9317c4c0664116ceb8b934eeaddb00c4d70547847e20ae686d9e2f24 |
|
MD5 | f98be5714430ae8d0ee953c6f51548d1 |
|
BLAKE2b-256 | 91ea1f377b87444272eafe135da5b9656adee7b23997d8d77b2a3d39ecd8d849 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 324c0038bb056ba9b5c97016b3d9c28b609f5f87b803857b474f57c6ce88b18d |
|
MD5 | 6aaab3a3d48946854d00f9e508a4164c |
|
BLAKE2b-256 | 37e50c4ca4aa9228df738b3b5538a0ad1fcc205854f12deead1027ca96cca754 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 98eefc5c50a9f3bf58c8709ee9daee8189eaec9323536adb4dd90a43753612e0 |
|
MD5 | c46045af81256336d27690cd5576d6a3 |
|
BLAKE2b-256 | 4376a29927009eff5e9179ca20d63631d50b875416133decee607b0fab2bb1d0 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9a00ffa6ecb5bac1ae4a7db5c2253e2511d1e04382b728d5a7ae18ed276f592 |
|
MD5 | 5d381175aba890412eb570390f162ce9 |
|
BLAKE2b-256 | 5ce8ccb56271ea79cbcfabfcdb682ec7db4387e75cafedca13462e2e95fde63b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91bfcccd731d1aaec1964a6db4ccf3fd747db27749f982dd99b7cdc1a75db58b |
|
MD5 | bb670dcb96feee402e00442f3b471aa2 |
|
BLAKE2b-256 | 3b9f0c68ceb75b94bf00602e07753da2db632dc4eee28ceab1d648890d50740e |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 888ffa1d149ad24930b27d5549fac6458b6d01489b940f74a06b0b22f10e21be |
|
MD5 | 43bb90bbc4173cf90364f3dc886a895b |
|
BLAKE2b-256 | 9b62010e99dd6c8f9240a486bc24bff5ad94ed076e5ebf7c2e5e71e4e3b271f3 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0949be7f3561970c7ac49d8fac26677ebe24ff4c72e1400faaa703b46e9f61af |
|
MD5 | c35b19e84db1935a8edf1468421da8d4 |
|
BLAKE2b-256 | 45fbdcd093cbdc093864a513aa0e2c1f35b3d717a2b150a48e7abb78a3dc1ddc |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8204a2fc77c2b059d5281312b9bc570c8a43961f481618de5d4c6eab89804416 |
|
MD5 | 3154e86e18e14acdb3e726de1c5997f7 |
|
BLAKE2b-256 | 445018ce1331694a17284a0e4e0a46103308027a35781517e9b2fc58c06c5583 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6839414f398a76482370acda9138a3ac9a59a0e6de9327f5e916f3620a2b5844 |
|
MD5 | 5b3c3fc6d65574feb114de493ad08468 |
|
BLAKE2b-256 | ac2c6e7932fdc29ac02f4a3e8306b891ec8f1572b235ba5b6768fa6f407c9a96 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ced8c85a4c047304bd684a6893edc95ec6a90052fc01006c1da33401c2d50f32 |
|
MD5 | c761c3222165ff54c1b618441d05064a |
|
BLAKE2b-256 | 4db436e52626ff55d20a118e250143480909a8d55fa3de12e746fc9889842fcc |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 173188d96b0c3f0f29dde23c7c125abb1d54f0d402ff8b0a199613feea9f4168 |
|
MD5 | 18633c019dd25c83e79f39b673358ee7 |
|
BLAKE2b-256 | 48a1eb99278b9c9ad70b236243dde60953315ea661d225bab288f5ef5795eae3 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ff56810fdfe8e7b3045bc5f591663b29432cbb6f00865d9bd1b5306534c2609e |
|
MD5 | 52010df66245b72577de66a731e56623 |
|
BLAKE2b-256 | cfdad0bdce86275f86c0dd200d88599f556c223e61fce7f17f200b49265185de |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9879048e15483c9afde34cfb1f986a3e0173cb367f93b7cb58d377b04dfbd81 |
|
MD5 | c82eeb8ffe68defbd26c17e9a9833159 |
|
BLAKE2b-256 | 919dc4b65e1d2be5e80448a2b5dc3af6783d096f55b0ece0273eb226967df8b1 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc74417ffd2265080e39fd33e835276708f29cb4a70b03fd0736286594c6eb8a |
|
MD5 | c93d23a5ddc6e62f352c295343dde10d |
|
BLAKE2b-256 | 23f49a6f4baf12c61154b05af22b1ba58c3f3a3eda8dc60a35274708134a15b7 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202409091723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3939751a85b215fb183418b594532db4b10ff13873fb08fbb7ea35d16d9cd091 |
|
MD5 | 4eaa708dff003d62b70a034b33785866 |
|
BLAKE2b-256 | 4744aad7040ae214d4bea79675bbc8b4cce58482e0b2889bd0a45940b71d6770 |