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.dev202408301723794729-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 24c1190502528af4c104eefbbd702ea895bb549f39412e60ca539616f7dbf684 |
|
MD5 | d9c2097d4514c9e82d660cfe5a716685 |
|
BLAKE2b-256 | 6e357e81b76114f5b93b2406517d43d9dfd1e423e29978d11dd81edce3758b77 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcea38c21384b0368d5d6271ea4565684a67eb1306ae53a0b38f5cac4ab55e3e |
|
MD5 | f40b62b2e17ca1acef47b73dec921346 |
|
BLAKE2b-256 | 337cbc7c618b0151baed54f71520179d392c09832f997d8b5fc1266a78abe5dc |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9f0a2ef646f549f6ee5c9ba46adcac5d96c5d12d7b0a84b9bd8ea11ba44f41de |
|
MD5 | d83f9c9ad70f52739805be8d68e80e7c |
|
BLAKE2b-256 | 64d3a31967b99feca2e0aa3a54d70f3712504f1404bf86a977da4cc0ac057715 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 32faccc1b891a5ca4dda2c5cafd7b1db1eb1b29e4a68fe398ccbbcb1877c3860 |
|
MD5 | bd7ef744aa276ee3c4d3d30a7c004e98 |
|
BLAKE2b-256 | 7469f41261ab79010c64ee6aeff7b13cc7a07d927f852a425dd56fc46a1a7552 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 595bd2cb08994ed3be78bc808bb03e5e03286db0d75e1de69684d61ede1f8ac6 |
|
MD5 | 43c11b5f5782c3a84a5a5f0d879903a2 |
|
BLAKE2b-256 | 7858061bfee863b9dd7d0ce0ee893b9311c1812637a5c2efa60a1109456a6bb7 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4f2da7f91c667f0f8e772beb733bc020c9eea2792d5b6e5dfea1c9809fefb5f8 |
|
MD5 | 62c0e0e106e328aed7e083718c74bed1 |
|
BLAKE2b-256 | f3cd72aa73bf08478489971367865f4178c7771304b103182097a91a0c9b3688 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b68861324a26494b76f33ad3b34690442dd844b6a93dd5e3263272c18c87a2e |
|
MD5 | 9ed725c5a7b770ead02ce144d35cc808 |
|
BLAKE2b-256 | b63276ec35190f617b2482a0070989be50bbe5289873c2b5bc66ab0d8e2c7f38 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 727c2f8a408949b61ad4f88e2e19aa22920a6937779061f922b694c11f39e049 |
|
MD5 | 33b566eab2f2e2788858fdf499a076e5 |
|
BLAKE2b-256 | 1b8cae79746e5d31a6f57ecd1da36cfa71ba7128cbf976496b719ab749b6f744 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d5f699953708ec5603e8c4faa957a3c7e05a2b15fe01e4ac02c587849689db8 |
|
MD5 | c71c888ab621a9add4ceb2d0c4cd5c62 |
|
BLAKE2b-256 | 376fed36bc0d7acd5aebbe222361b21a273448b926295d8a2443bc0fb8282f5f |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 48d12bc8065d41dd164ee088de03ba49f7e3a56aed3bdd6f64015ced7dfa8db1 |
|
MD5 | 8c7991464782fd71e69e1e2fca2280c2 |
|
BLAKE2b-256 | dc78de296776fb013af95d21a340b6c2376d4e582bd19b88c75badc3dac015a3 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eaf79911262183e917dad966eea8ab12e979b5ca747f71844b8b26b314a29ab9 |
|
MD5 | 7c28586c79389b2124c5ce3e2fcea7a7 |
|
BLAKE2b-256 | e6e515e082cad24200f75453cd2dc0995433c25970264d80453e20a7b523b0b2 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ad66166cca417d28d36c97911a43e0119b29c09ba7245ba4c432608f544c5333 |
|
MD5 | fe647fda2f1d9e0d524530dd41d914e5 |
|
BLAKE2b-256 | 8567af25fa06375ad78a2bbd3480fce84ddd74f63bc860b7a62577738bc674cc |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 790240e1789e8e18308adf8419027f7250361b4e47966c47db7f92b2da18db4a |
|
MD5 | 091d6b95f7af1cad21ec6e1a7dfe308f |
|
BLAKE2b-256 | 3a52a38ab224d2b54ceed5ce76f37f334cc9ab6ce871b3e8ac2db7624cf95da4 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68239f078dc26607dd3dcf72aaf6f716d690e0bc7e6bf2278dd68c7bdda65584 |
|
MD5 | e6f054048af68f3969ced741d48d4eeb |
|
BLAKE2b-256 | 85ba0b30d22bfa5ce1e8ed8e1cf7ac575b72bf1ddebbd22089fc532e97892369 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d4d240785b9523da3b816c0527d7a6db718c3113af5238fdbabf5b0fa9f69ef |
|
MD5 | bc203541dd9fdfbb33b0d88dee38e365 |
|
BLAKE2b-256 | c1291c6a09aa76031de02cf290221446d06462cdaf808aa69d0ad0a311a37166 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10da7d6012fd042a1bc8848811fc3fedc78cccecdf609ff10c4286f588b358c8 |
|
MD5 | e9bb66c5c7923c1c4d9ac29d2ac4713f |
|
BLAKE2b-256 | fc678cc0dc42b43334dcf52b37fcf2f53c4a316680572d49da5e026fc4a98d29 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b9bf693712ee5f943efe13dd31c21c843b086a6136587919ae7d1c409f8b6b81 |
|
MD5 | 07a522e99843162393e3d6dbd85b257f |
|
BLAKE2b-256 | 03836b93c680623af21790732e71c7b48a7a4602e41f12824dedb608fee9ad52 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6067a77f5c4571df79e8ff1778331c4ad92c773b00556a3b1420d431c6534812 |
|
MD5 | a9084d250c5c7b6fba7a1dcaf4543df9 |
|
BLAKE2b-256 | db94aad310c5345860d38d58279fe236a1aa37e13aeaf9443641b022f03ad582 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1ff76c0cb31ceb5075d92a96df370bd02e6b1cba263aca4868163f392ef1f72 |
|
MD5 | 884e0a9fdf2f49dd421eb1a1c584ed80 |
|
BLAKE2b-256 | a7f511204234698ff17ad28c2487e7e5d7ee7589610af36f7dc11c87d58d6e89 |
Hashes for pyAgrum_nightly-1.15.1.9.dev202408301723794729-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d8ed55fb328908342f2d48e55d9369b4f482ab2cb59ccecc48227913bcc8303 |
|
MD5 | 7e21048f69bdb1404e45f82f6245ffbe |
|
BLAKE2b-256 | 2bf3b8e60fb38553b9045b85c354552fda4ef3568c1cc61d9bbe6b35ed803bc7 |