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.dev202411011729615378-cp313-cp313-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9b1b9735c9e0cc7f8a109e5126df9348536d01c406f234beb9fb9db175312f6d |
|
MD5 | cf5da0bd6dfcea84ea15408fd384d488 |
|
BLAKE2b-256 | d388cbadcd5a614e655dc3392685a4522f80bf006d11432e25fc56b3817003d9 |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp313-cp313-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | addf32436a2fc499dd3732c820bf30e2e6a6990ef373984a68e53c18bc7852b1 |
|
MD5 | baa649a5dfd11b0c87d6cdcd38a48f88 |
|
BLAKE2b-256 | 2d779b8be881bfed8fccf06b4d469b56af7a2b7c1078953adee078b1ccafa59e |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp313-cp313-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ceaa459e5817fccd79e934322f8cad1506455001818ffdb54ec5c57c4d83624 |
|
MD5 | fc825f1821f633900b4910067063f1ce |
|
BLAKE2b-256 | f3e1000987c8fa1a9f9c676843093703ef75e9b9302378b3e3d2eb8abc708f20 |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp313-cp313-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5535ae7e798587b0cba518ea926f074cc66c6ed68b359600daa917b3ee6ae8df |
|
MD5 | fded8fd1da1274fb83c728f145c4a0de |
|
BLAKE2b-256 | f0746dd317534e9ebfeb03d51356652a1c9392f756103329b90ab64fc510050c |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46d9cda8552f94f3cf86c908a9983c2a6e68e2e33ae0864dacc3d532e4999e2c |
|
MD5 | 4c331cac9ab5f30f51806593411b376e |
|
BLAKE2b-256 | a2ca5c9f1eba71a00c345fee46b958acc1ac2d68fab1458a022c082479ab0a50 |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c04bb4aa97116a456797939c7d75de0e3af230e149682aceff94929252adc212 |
|
MD5 | dc93c62c22e78dbef1653f8d3b8a8601 |
|
BLAKE2b-256 | 1d5b16f3b8b7a6f415a08c6a533e701f203970cc13f38b5cf71994b65115b370 |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c76b33ba4a1dbc842b518106c487bcc9d74f144a552a47b10aaad64a7c0567a4 |
|
MD5 | ba70fcd1ac8d99b355c263f78b411a0d |
|
BLAKE2b-256 | aa4ddcb44520db5d5d043e841b2675a8c46061e45ab5140c54e657bc9a4f17ba |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b2e8db7cf99829d62c6b2f7a17593b134e1b2d3501f4b5d9964ef6ac22fc804 |
|
MD5 | 7594812b90ff7f5533566dd785af0895 |
|
BLAKE2b-256 | afb860a54cd650166230b17c360168a968256e35d49a2ef41deb1ca0a26b8c8a |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d27bbb1dc3065cd4affe25349c5896204394108cfba142881fb41edf269818ab |
|
MD5 | 71fa6242bbe7298d54b757ce34783d67 |
|
BLAKE2b-256 | a10b2b8b9efbde8cc2cad43ff0a955c983d059cee81cc01ccae466fcf41256b7 |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1a5c744640962c5528ac235ee6bfddd514b5d584379010716d28e165c022f30 |
|
MD5 | 357da8fd6d5764a50bee1c456af7c87a |
|
BLAKE2b-256 | 5b6eea55c84dbec3868473ba9c6e3053f87e4805e90d0de075980894e3ce7990 |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3867244a93b23651ca380fda1e15016f1464f06833cfe356d5c8b7e79e6a596 |
|
MD5 | 920030de26dfcafdef714eca43e38bda |
|
BLAKE2b-256 | f384614e49c4c3ec783a912894ba32079a66e19bea122f5ac840ddcbc65e3497 |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3416484ae98a097ddc3177dbfea1ddfe7d825c86c4fad9556ff287452cd0d741 |
|
MD5 | 496ed20016657430f75a0dac7b286197 |
|
BLAKE2b-256 | 9dc6e1cc737a9356cce49b56df0a96792b604100a6443237f10955b548e24eb6 |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 294cd4004cc822e9bfdec3fad4f073efa5fce49b6de0f5abc0c9ec3e43d7ff88 |
|
MD5 | 6589609265fcd54298db47055d8bc1c4 |
|
BLAKE2b-256 | 88909afc49eabea4ff11b2fc9fa62dfdfa4b61b4890a2948f7072e39c36d4003 |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c9774ffe35695578c60349145505e91e371d9cf7ce4a3059f6d8ccc26495ac4 |
|
MD5 | 0af00f805f61812623aa950956a62b77 |
|
BLAKE2b-256 | c968d9896c64f17d83216d2ae2f300bd95f2ae8a84e06043d5aeae03a7d4bc2d |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0efdea27af5374b49881e96819314041ebcd414eea2471d632b1b3678cd7100b |
|
MD5 | 803801b9f694db5f9d3dd66e25e87c4f |
|
BLAKE2b-256 | 142874ef302c572ff1d93999b9c4cbb4cd7667687c548e73c813cf189d45624e |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1df25541af49eebdc19a66607626f049106bb168549ec09ec7fba6055b414678 |
|
MD5 | f82bc2cfeabbce9a496aa3f01f74db4c |
|
BLAKE2b-256 | cc71cc5ac1fab7380326836880bf9d2ed2f4baad28574de74e5ddcffed1d8528 |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27136d1d98a153882c9d4bb4f2c472af4ca3cc06302fce6af56e5c8c2cb8d9a2 |
|
MD5 | 3ef5b89451e4bf90450314aed9dd72e4 |
|
BLAKE2b-256 | b8dc3d978be37264559d2c0d8264ca819d5cb67576f1161027b3132a5fa88a8d |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9272381a586c8c6037746950cdb96089ad546df647eb7571584dc4801e2031eb |
|
MD5 | 3066fe2db1857313adf9d68d3f54f419 |
|
BLAKE2b-256 | 806d075f25c205630e73ccdca871af5d0ffe24fcb0cdf687714746c422c473ed |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b422dc01ad4247b3a5822d8b8e553380f5a9f435e30af236178f9c44676607dc |
|
MD5 | 55c393cd1fafda32dd041bd5606d07e4 |
|
BLAKE2b-256 | b6d8395cdf7e6969c662113f5fe394c9e9a40e0d00656f0b1746cbab7031fe03 |
Hashes for pyAgrum_nightly-1.17.0.dev202411011729615378-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1fab52af18f0676886f67c6f98d1ffbbf3ebc005d7fe7b4e228050c780c146d |
|
MD5 | c695301878f57882f238adb7e59d07e6 |
|
BLAKE2b-256 | 58c2fc712e0ccdf096190117f715b06475841c6e822a9c163bdf2e7d5805a518 |