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.16.0.dev202410011727562243-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fdcde91abde572e3121d200f572b67722ca7b10d83d1d32810630e2ff8adef11 |
|
MD5 | 92b26e4102f260d73793456c0d1ced24 |
|
BLAKE2b-256 | 8463f98711ab2840b9057a827cc5ea189da75c75b737d3d36963a7e3ee72c515 |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ecad90b93ac5f4f9f9e966bc9f76fb445e0f128946085452b03c0512061eb93e |
|
MD5 | 60a39ff1035bcf35f9a650d4199c3e59 |
|
BLAKE2b-256 | 165e53ad8df263b36555997b4fd040e97c4a0889af3926bdcbb4164df4d19c5f |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d46daf454486410e480d0322efbf1d13bacd254e669b7fca77278c72701cd918 |
|
MD5 | fcff708012b62b3f094e5a06506ff5c6 |
|
BLAKE2b-256 | 2200bccc1396bb36e81180d7cf450c598873756f28eedf264df188de48517c53 |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf8312168b50a16f2f3c04bf78ce03a10fd38e3ed7875af5269dfabfe8b61139 |
|
MD5 | 9c117f5aa1d484f0383ae0fc7107e323 |
|
BLAKE2b-256 | 22a972d03df5956cee47704713912e1b14a973b055bedd9be7db8369fc223169 |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9228a7c777e8f95d3780309169c8f3b356ea33039b6d2d744369d64c1c6d66ce |
|
MD5 | 9dad83924a96b469e000af890f01f701 |
|
BLAKE2b-256 | b72faef65236e04bbb10ccf770ea7bc3f565be52130084df9eeb44a8ad0f11eb |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3d868fabb050961647cde8a4d98dd3e11556fba2bb66d2d77c29e0dc5b02b68 |
|
MD5 | c3bdca2ef931923abe87c51a425d0015 |
|
BLAKE2b-256 | 5d220aeda18128f34c8a15387e70c75c37514b9ee7cb7e2604c0d2da8fd99e46 |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 09627cbd151ba8b9a1009f86cbd5edff070e5a805982bb4399fa331bd28d63c2 |
|
MD5 | 3ce2c0c6e12c0eb56672677ce55ca507 |
|
BLAKE2b-256 | b72fa5ddc7e0598f027abc0becb533c718cf46d6922548d943464155ebc4e01e |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 223f764e09e8ea46dd16be94065182a60b619f2bfa6a8b302ea45fbbfcfe9f2a |
|
MD5 | 91756b318ed30e5c81d190f8bf2e1e94 |
|
BLAKE2b-256 | 398cf429abc1a8988cfe04e7cd3d22190c14e085946b58ffc235bfe0a0566d34 |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed35890f0686f8e4e29ed62d594adfa77b3bde699ef6b6e3bf31f0e5929e664c |
|
MD5 | 0efc74e3ec303bf9bfdfd31c51310d1b |
|
BLAKE2b-256 | 3db6b0b282a917ef84b74cb9433f4cfc5d606fe467fe24a7ebcb4d6036287f6c |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7eee319ee205f0c5dfc1f6a0eb80cbb68d400d6a3f452ed663f9434beab454e4 |
|
MD5 | 2e37c0d4353094fca1b56c04aff77019 |
|
BLAKE2b-256 | 7f16bfa648f7415fbe16b0dfffa69fa19735afc296edf8f4687c859b3215b293 |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97c95f039bafd323d3c1ba169367038b0d31fb38ec3c3d23a30e1bc97776f81f |
|
MD5 | afdfcb9df35fcd1ddb37e07d880fa1de |
|
BLAKE2b-256 | 9c0a770daf3d07b6e5eabe7347439d38601cbc788c925d96c60a8a58d83e6947 |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df4d1cf46ae4a45de5e4a3042f5667b6771ffc0df6d02147513fe940f5135efe |
|
MD5 | 95d57f75bef4f9d81804a0f0a2a820bc |
|
BLAKE2b-256 | e067e38922aec81b743fa6dd4e6cbbb0283851a1a37c0bcef706e6b131d540df |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 259cb2778eed95c22b416efcfbd9cd88b617f35b60647bd597e55b3f17a77481 |
|
MD5 | 2a4412557917f7888092be1938316335 |
|
BLAKE2b-256 | 0cfe7955437d31c7750e983b1c01103f335bd2865dce1991bd7e77da4b4894f6 |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e43b0c4353821c8a7af6c15517a3949c916eb7a865a5b3d63fdc3bc66b8e0675 |
|
MD5 | 6aeb4c39f0522c62505b72636c0bd9c3 |
|
BLAKE2b-256 | 88fca70c3adc16e5914215a9d35f6a837db83cc5106f7ab01740981c52bf5a6e |
Hashes for pyAgrum_nightly-1.16.0.dev202410011727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7592f67ca6eec53e058f60b78edc9cc0377405922068dad72ce0f73972fb561 |
|
MD5 | 6f1d794ef6c91a41aecec226a5acba0c |
|
BLAKE2b-256 | dd8436839690789ef97c4dc907bab24a11f94e6050890095e8b626c44d99b9f4 |