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.dev202408171723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a99828d3c8ecdb38391a2196b25986d08f3ad9e270fc828095f9ec6c7219887a |
|
MD5 | 3657db74b14bf63e3ad5ad00e07e004c |
|
BLAKE2b-256 | 4c8b9cd24b57e1f398468324829d4ac34b28499544dec24ba7acd1e2a96ec8db |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c3df6475fae2f296c651eeabc7ef1cb52e35591276c2b15ccb1190ee83953f1 |
|
MD5 | 32c82b2f117eb5503cdc7f1360080545 |
|
BLAKE2b-256 | 187a647168a5d9d37a9e0777fd643888abd1992812871286a8f2a473d8e13c9a |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5be366e409e85fef36123e6466ed7ec2b2d9e0b0297c4717ab19c2e6710c3d7c |
|
MD5 | e3dcd57d006435ebc3871eca2e0d59bd |
|
BLAKE2b-256 | 6f1b6a3a001389bf843b5d04881110210d9e6657e41fc0999d8d8e48b67aa551 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad7a3ca2d8dd0c29eb6ed026d182f7c5e4d7178216e468c7a90e987be4e9eabe |
|
MD5 | 0a0fc2243023d89c2f0981de53f8ca25 |
|
BLAKE2b-256 | ed2da6ac40ef283bc8573a62f500d5848271b1cd84be88abf4af319d711f164b |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a856404cc9f8a564011db7323d949e067baeb56b8dce34bfd55836b255744a3e |
|
MD5 | f1e6064786782fbcac3432bce5dad6fb |
|
BLAKE2b-256 | 451975f5d36a7534d876fabfcf1b40b75319f3680fe36184b3ccfe63ec2b975a |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c408170c36213b818416db271d4ece6b6eb1bd83549ec331c831f6ac3403db9 |
|
MD5 | 5e26b281443a154290b3a886dc35656f |
|
BLAKE2b-256 | cca7a60b7da3a80577492cdc7752ff8b70a468a4550a814229ab8fa640b24ac7 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 277080e1792f3cf83ce92d2cf3a0434542c5431f9187c68b0ce0d6522d1b2850 |
|
MD5 | ad6425c4070109c54d8a903f61322650 |
|
BLAKE2b-256 | 359d69f952d0e0646b30401571459a18944f16b3fbde973407c5533a2e742378 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8dd9f03b4e9e0d5e88c02465ebb88a778dbf2faf204717a45f152609808e45e7 |
|
MD5 | 1d610daebb40227b674af5ba57051252 |
|
BLAKE2b-256 | b16f273b373dfc6f7182dd6713ad4f93a7a7eecf7b0126a48ceffbba6e57d7b2 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70f2b5777364cf006d98ddec9aa754a41c995b193f409eb12aa2056ef893d533 |
|
MD5 | 6e766cb3b7bc770de6cba92765e7f09f |
|
BLAKE2b-256 | 1fa571cc65b33dfbc061c954ea06f48c1607b3460a3fcd26d27470c0d30b1413 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb065a870356e698cb3d21c3c6c88d39fda63d43e4e5cce9a572472f52634870 |
|
MD5 | 851ad057405fc81da7125b1382ddc3f9 |
|
BLAKE2b-256 | 64bd82c814c3a89deefa8d363cf1735a2c16d7ed0cb4bd566187dff0fe88d052 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6db5526a2645291253fa8001cdbf62dc1d9796aab683b395f448ad762fec86e2 |
|
MD5 | c2dad23313f604cea325d93d410422a9 |
|
BLAKE2b-256 | 876cc94f96f34b809f6382eef7f0dc787124bc07e80dbb415ff3fd02ce06fe9d |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75b3afb28107601b2d31e7086639f691035932fc4b5a7b1e38c4aa46f722c70a |
|
MD5 | ff9a42d316b5274504f02d04e70600b4 |
|
BLAKE2b-256 | 81db73b7ef03c87f83004778377298d30dc3fc5f414f23efab9e85f5df27a8bc |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c8ee745743a4343794ffe31e4577c5dfe2a61a73126d9756474541b75bd2df5 |
|
MD5 | b73b9226612b9f4d6365ba8550c1b26f |
|
BLAKE2b-256 | 0aebfcd4fbdca473f54885adcf80fbbe3a9e754a20419d8139376a27741a5085 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 741a28ce5055b4ef9a2232aff1ebda409712f6cd9a4f9731ad9770aea2aaf0a3 |
|
MD5 | 1cc421b570ce545da4a1b6df54bfe00b |
|
BLAKE2b-256 | 1c097913491933cd5ca210326cc649d2a03e8cd9fc1794179c25073bf365ff89 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c05ccdc30670306058641ec822badce7dc9024f8797be40a11fc76512818c78e |
|
MD5 | eba7a48e797161d64bbe82680b18da56 |
|
BLAKE2b-256 | e4ea8453f61fd7ed3985b021f1bd402d6c1ea9efd020b5bceed4834856b24a54 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49edb13a5eda065840f91e0b4a7764add0f8f3bfeebc3869bdb85f6777d19a3f |
|
MD5 | 00844160d166b6d6aa967ecdbeecd7ba |
|
BLAKE2b-256 | 9845fcdcb40cafeee691d6589274c4562ef3cc22511629f1b800f0d693b01550 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5baaff530c1cc0bdd7e5a7f35742c3e3ca2bdb307d43fdcf5489a6f952faa237 |
|
MD5 | c06d9abf8f3c08df9c3c7c46a9218325 |
|
BLAKE2b-256 | f3a06924042e3f8936ac3ae2dca5f50b7a954d3ae22ed3ee21999046c88433c8 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdb88c8d5dc191fb7fbf1f7e81f3558ac5a44cc09e752c56d5417ee0ba56c846 |
|
MD5 | da9f569a7f3bdeb3613155b282e17e9c |
|
BLAKE2b-256 | f554e9f2bb821209006528c107e4555fcc40552278b6f57eeb4932279b10b1d9 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a9d54a86a6080e5e7630a96f097c2c247ec2bc7294c8b7310c946bba4a0cfb46 |
|
MD5 | efae4a443e169ee286273169b4d7e8b0 |
|
BLAKE2b-256 | fd99979312aa950414d313f492088836a56392b1c401b2b56d0bb64f8a52b45e |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408171723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d05a5e5871b8dad3bbc0b5356f6f42f10da3107de3ea23e8b62854f691b054a |
|
MD5 | 0b2601842322f20dede91ca3a39c4964 |
|
BLAKE2b-256 | 6f1dd36ebac3d86e107cabc10a8a446d45c89251aa53883a29bbd150ea4bf435 |