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.17.0.dev202410201729248609-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 423204a496779cb04a573ff8055227b265009f4fc74a833ee2447c35257dcdf9 |
|
MD5 | 6b9015de8522b0c02839f9fb1aaa73ba |
|
BLAKE2b-256 | 635f8eb2a654e37222fa2b89e7eb0006ebc00dd713d7a5232af6dea82b6c4bb0 |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp313-cp313-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c659298376ec9f6bbcd191ac0cab8811bfae3672052bb0dac7a06b8aacf7206c |
|
MD5 | c1c3db48facd0c09b0984d5d1990e39c |
|
BLAKE2b-256 | 0fff100f0b3211df24878f2071b702523e2ccdea70f0b0062f21fbaaa8a91e59 |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp313-cp313-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c19b8ccc83541d0c56159391e9838adb367426dd356f45f59c2631d06bba7797 |
|
MD5 | a116b30b6470386a77e3b2bf250c5d3a |
|
BLAKE2b-256 | d4d0172daf81599ce0c6806c4358e0e998d8146b4bc28fadeedadf5777ba4410 |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08df24116232574494417c64901af966b408540b26e78b61c8a5ff06b0aa26b0 |
|
MD5 | 4c63f2e86b0d3be48fc19176ac1de515 |
|
BLAKE2b-256 | ca1555a9d7fcab834dde494c7efad143f19b35271e863fb056b1f07beb54ca09 |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9bbe0b73a478fd713bf008493dc816edf9d218a1d12e34086796aab3a287d66b |
|
MD5 | 8d05904398e106e968a07e187abfa122 |
|
BLAKE2b-256 | 1236436d2063bc1c39513f4373db9dfea2483299336a0157fa391157852cacd4 |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47f6720665c9243c0667ec6896ec21090bc49187730b19747e2656dcd34e57b2 |
|
MD5 | 612b950a45b19203c54e7d44948bd8dd |
|
BLAKE2b-256 | 3839473cb0aec0df41e38fe48150467aa8233c336068da45824f97e8d9d5bc8e |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f42ac78b18502f617b486612a8c1b739eaee91d0dba5dbc846560aa7f8d2b4b9 |
|
MD5 | a8d89aa05677c35ad6dde35b609285eb |
|
BLAKE2b-256 | 596a07ab307ba412fba9404cab8f9a136db5f76fc996eb02df23c52678409e55 |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a68cac056fae57fd78d7421e94e4e6cccf5a9151a982ee7ef70e5266dab03cf9 |
|
MD5 | 14b5c2c07fcb8e714b5878190c03a1b9 |
|
BLAKE2b-256 | 7d7189e17ab4a8c22acafee3377e9c79063323e8e966116537c7f23075e7e88b |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1191810db7546112210ca715a5b6c4b7dc346ad42e2c5e4dced1cbe893a6dc17 |
|
MD5 | c60e34c4896860cdba55ad6f90bd49a7 |
|
BLAKE2b-256 | 71ccaf85e3b0fd0c62329d46f92ea6d1c39055cb818202502b9708651226e31f |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a8f7a643439b39652255ff4bd2ae22daa25eded0234aa32c4bfa58d26fe84b3 |
|
MD5 | a51714ea55c4014f5aac98c9979bfb19 |
|
BLAKE2b-256 | 6c24ef477e92e0c0c61a8604add01d5d910369e695c6fc648582a3d24d3ec6a1 |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb9fee1f6ea276d6b581588ea587c83649cd5bf36c5530ef1c9eb081585799a1 |
|
MD5 | eee3fda7a6033751dfbd63638ee7bb70 |
|
BLAKE2b-256 | c497bb437a3746e6a8abbb72617b98f204ceef294d3f3887027a0c3a2458de1d |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78cd421e1f7dce534d4459ecc64070f96cd47afc7730b34776056de685414a0c |
|
MD5 | 495416eab8f5e1f48339b4cbc54e722a |
|
BLAKE2b-256 | 4f7192edd33c49cf7f4c586b21ebe3bbf0f813e09a0c0fd6574b0c33c8db668e |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8819fa8a1786495797ed6e8b574a3c3a4878d68efabfce717c1d60eb0919eae0 |
|
MD5 | 9dad1b0d211a79e9f7d51c94b947b46b |
|
BLAKE2b-256 | e156f207d0f125c8deb4adbd52bc84b8a1c9ae4e0216f7b9e6cc9ac021cec582 |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4524ce9d438ee9899c0efc320e22192638943f23a5d5b0b883f21f9d30070723 |
|
MD5 | 8ae4bc1786fcd0b99ec89f66c3702fac |
|
BLAKE2b-256 | 55807e9852395f6b6dce742f31a08dbc4cc2e517dc462ea719d73d8681d15f44 |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7296a4b6cf430e7b9fb3cdde4d0ded08e9dea62d0f17efa8d29941be7fb965e |
|
MD5 | 341ed312c64d9cec59e68893303be2df |
|
BLAKE2b-256 | 28f5f9a1854216db2441fd48fedc88135c588b748f03eecb4571b696ae45cf6e |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 78387f17bdba1406b7b3a9213d1f3666a092cd039ae66cd6d380054a77da112b |
|
MD5 | ad019a0c61371eeb12a8a613db240ab3 |
|
BLAKE2b-256 | 77a2e901643950ceed5cac3d8451e3b636edbd789475ddb2699f1e51d3f6ccaf |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e54387200d7117f61b9e2206d7a14f40202ca1c9e25d306840573c0ec23982c1 |
|
MD5 | b08e89a32d179aabfe2b7863e4faff37 |
|
BLAKE2b-256 | 6b7a25651aead09db3c348a4a47295faaa70429b5c368b766526decc831abfba |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8f8ff507a6f08568a91ea6b62846a4faeef96e6b829815de95e145732305e20 |
|
MD5 | bd49d90720e7e0720c7f9578ecf1f3c5 |
|
BLAKE2b-256 | c60d504f9b15b276098f9968780be74dd18047b3abe09df64a4d8c2f2c103217 |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a87f8e50d73bbee87597089bd02a8131414556f5f3c270ce41588f0103cc47d0 |
|
MD5 | f10b80f3e26aa728511e344ac1f3caa9 |
|
BLAKE2b-256 | 9ca44273b45d075ba9d1dc22458b5bdffe457e3e8bf930f402268b2f62deb8b0 |
Hashes for pyAgrum_nightly-1.17.0.dev202410201729248609-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cafed7865cf5989ebba7c84463e466e805fa47dc166df7f3788acb60970f2064 |
|
MD5 | afd5252dfd2583d2099265e82772bdc9 |
|
BLAKE2b-256 | 97c043221a4a43163f54737bf9908de30c9b4e5351e611b2d6f51dd2e77499bc |