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.dev202408311723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b637111d15f780b4dca5193670185a110cd21b9d93722cc2c1a9105f8d47d8b |
|
MD5 | 433f07a428678bf3064347ca32bc0687 |
|
BLAKE2b-256 | 86260b33b6791efe55c5472748be3040bc0120c029e6651003481e4f8ee0c31c |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 14c7307f24747ddf924e6d3dbd6b966ac505b00cf88c03400774657c9d05be09 |
|
MD5 | 95e6fab621cef45b7afe9cc79461c16a |
|
BLAKE2b-256 | 1390df33778e5db3d1a7cb4e1e1c9f95c7e6de99b344da26ad8a55ec7fda0176 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cd436b5ef298c5da96d824dc182a1639c1b262cfa8ed32259569e8278e2b464 |
|
MD5 | 4d9e0583e697a93457c0df2b4463389e |
|
BLAKE2b-256 | 1f19dd002d2c474ad9b5d69e4d409b9924da6bad8744f586681afbc8a0338873 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d370e0ecc7f797ccf1f83d20c6d8f83ef742abd00c133df78b5103ed751d761e |
|
MD5 | b37875b00c5dab089124da01f50d40d7 |
|
BLAKE2b-256 | d5fd812c874ce804d1b002963ef24dbaf206aca8f9d30e1ebde3c5ff8b06a422 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 543893d8dfc99b41936a9bda4c7c5a537bb5254c1c51bb8109f8f07527dcd042 |
|
MD5 | 56adff160c0f9017f1ce494ce85bdfd5 |
|
BLAKE2b-256 | 3c64c0881b3cbf8d32312980d890118d36faed8a3e29eeb37bbffe6ed52c9a9c |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c07ab7a7fb848137470d23879dba3082efe82f057bb28c5a606119650a8a5dc |
|
MD5 | 8b8782a95b91bc99ac8b67854bd775b1 |
|
BLAKE2b-256 | 99707891911713c985e1a06250a023f048d18a888128f1b0450af5dada60bb23 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c260c8bb4bbf981eeb8fe560184883ab20b8a9ac8033e59577ceb5f1d02cfb3c |
|
MD5 | 52f2ef38320663670178a138da5fd9a7 |
|
BLAKE2b-256 | 1efa609a30726d58bd70ffaefa8ef23e0995acc4280ed2126221f10086f6a1d4 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f61554e5dc31c42df961c76b0949ee4d0b1cff0bfe36dc86aef2a58296670f4 |
|
MD5 | 3613f5ca08a07c37bc611aae3fa5a07c |
|
BLAKE2b-256 | 103db908773744204ca1c17b3933d96ebd9b797a29cc07e02bd5a6b4e2112e6c |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da9bfb6ac9d925c0ff6677c1a48dc582c126348e3c23ec471c0234683e2e7359 |
|
MD5 | f711ebe67f336e81b5bc05650507895a |
|
BLAKE2b-256 | 2b4e0609c1b4fed67f4c19933d3fa953d45380519a140b0f08ac74542137c987 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59821de20daa800158e1ecb77430f1bf3c87202125d308be3f2e96aca71c4ad5 |
|
MD5 | bba2ed89c8d2da0f85dc25361337a818 |
|
BLAKE2b-256 | 5652d2f82312c609ab6840eea75297a42c0b3222b784a5d90d3fd57fda8fbd7d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ece45e75629dacca3780ab09b0f39c70b078a997a26f1058af7c0cd7808506d3 |
|
MD5 | 47acadb505026d777a658cb4e10de0e4 |
|
BLAKE2b-256 | 50997e5bfcad54ca2e9f7dd1dbec99381be7e3cbada1edb7ad033120a100c68b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b30a47b288de4bf95879d4776fd463c48ea5f1a5c67daab02b3393bf1d823c1 |
|
MD5 | f701e0a7edee33c68fa6501e5da4d600 |
|
BLAKE2b-256 | afc385edd511436bc0c412f6061381e4061aa39af81766cc68fe369acf7c3363 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 33668753f3f38309b245a42017e50271bd9c9cea83f449af248e0968286d9af5 |
|
MD5 | e6c742befd552d8191a51998296e57fb |
|
BLAKE2b-256 | 94effbed5bdb4d1a3b57ef48636237b5bae677078fb4a05e85d9cee8b1b1f21b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29d6ba574b7bb879e8d3a63f7ec16fab3a30f88fa0e2385a1337b463ccbb259b |
|
MD5 | 160776966ec4f16942b960f83e13f124 |
|
BLAKE2b-256 | b8002630ba1b896833c51260f136a61cd4332b347512a7dbac0eceace142e98b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77bd97cf2891afaeebdc7570b6ec7049e2123cc98a702c0638aa319651217f5b |
|
MD5 | f714074edf5622b3d07a653e882d83c4 |
|
BLAKE2b-256 | ae903d24d882cdb29e48b1c9292185dfc06479de94a6c42215e0c7dbfa961db4 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b5dbf1718b6531eb79b1170c5a37d6ecf1b512aef142b4e2846100db3b3fc1a4 |
|
MD5 | 8a372f3772085c570dff2e1a811fd51e |
|
BLAKE2b-256 | ab032167abc0d068ab88ba52b83a094720e520c23470650127c2fc8419c06970 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9b61fb5661e663da2b3ef1781a212ad364d110179c27c2c001dac2960c6f986 |
|
MD5 | de7c16873a5d3a04a26dffcf8a5c1107 |
|
BLAKE2b-256 | e4d298199ddc23ca287302d3b348ed0b036a184f0030633b27487fc9375f3e8f |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5f868fcae7276f364dcea04afe68ab7aff1c5857379be34d733518633381786 |
|
MD5 | 6b522142949efddc35da2a337363fee4 |
|
BLAKE2b-256 | e7588eb5409f676b662b41c5c8bc224701675a000fff029a6530c75aaa02d625 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 948d8a5d45a18dfd305d63073a2878eabe32c7db9a8898f75b412fc514b43152 |
|
MD5 | adc3376fc38267f1a1012e4daa298619 |
|
BLAKE2b-256 | 582808ae45c25440a3c9ea449a2908e22ac7143e21446c1955d6e054bdb47df5 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408311723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e059a77dfca54bac755b5293f2493cf249215f01ed897bd5d7993c26f8cd3fe7 |
|
MD5 | 6beeab8c0028e3a7eb5419ff84eb73d9 |
|
BLAKE2b-256 | fc88d3da7864bb03600e218fa1c4d935405f4fddb2a5f99bcc0c6a5f364a2902 |