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.0.9.dev202407281721169663-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2981f26caa4570bce1e7c05b527c6aacd9b6ae50adf3cccb58855d78ce64ff93 |
|
MD5 | 056222f8eb9dd63199bc25ad4bc76d55 |
|
BLAKE2b-256 | f55f46858e53f525b14040217061218ef40dd5c455800db5117d86a1fb8140e2 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp312-cp312-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3768ea0e9c5b33a0097a7adf9339b1acc197a9ebb00d3c463907a4b7394e1c8 |
|
MD5 | c9d4be87df3ab92d4d6feb80e5925174 |
|
BLAKE2b-256 | 637a2cd0d1afc8be1a281d71d9682e54bd7f56b6f869be0a3c2958eb564808d5 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp312-cp312-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3bdc2e16dfed0b833b4ed942ce1739f2e2bc6ee8c2fbbce01f1b085a6e4e7d5e |
|
MD5 | 61a25b6cfbee14d380993002c32e7bff |
|
BLAKE2b-256 | ff0807b9fed9c142485e0562488c1f76f05db898987994f50ab803a8fd385eca |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp312-cp312-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf664e582693f7fce899378bc17beceb5ad65261cb2a95129f5638c04f222b0e |
|
MD5 | b9f5f2812fc302b410daecc0714b1414 |
|
BLAKE2b-256 | bdae481dda33d284e125e018a4cf1f833b80901ec72c1e9964b946325e3508fd |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ed288c90f3b137fc4f238d33a157156cb495726c80ce342ed754129e1ceb218f |
|
MD5 | 408cd84c8511d7440bb380b103f0a4fa |
|
BLAKE2b-256 | b61b4a0e193ddd45d92f605e832cd70a4dc1e2cc86c7060c319e494b57c720cf |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eb7e745f7292ce7a85f2c6884acfcaebacf3c611935c9ce714e3222b1faea783 |
|
MD5 | 91d85d04b3b5c741121f3f7e6130935c |
|
BLAKE2b-256 | 1afb4274b287be211b918a4e1edee70e310f1e516b6e37db0cfedc276a276be7 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp311-cp311-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5edccd8fdf2ecd5fcb441c12cc45e42fd41d2c3422dd5146b55201d2241edb98 |
|
MD5 | c42eeaf0bf5452fcf7ada135e459a121 |
|
BLAKE2b-256 | 51fdbfb0d09f8ce3955327ad2c92682c7fc87e3232c991c00a7ef5645191125f |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp311-cp311-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1585e68363133c73961decb13fc96d5fac4cd2f6443356b97905c56761f7a43f |
|
MD5 | cdf0c0bce1b521a440330ad0d9cacce7 |
|
BLAKE2b-256 | 7f46c0b3d03c4f251ae55396903f3f3e5a02943e633da36fbbaa089abc3970d4 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a48e48f273dd8176f0cff6c662350851073967d8e92a2fd719273ccbafc5fa5b |
|
MD5 | 9045cbb8be9a9dc5e3af7611dd4217cf |
|
BLAKE2b-256 | 73e9ec46f85342cec77f9c0eacaa84cb7fc8b4983a00cbd3e1e80419b2352c92 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e1ee1654c9972381b48d22006541c660795746b693bffa74759b02b7408271a0 |
|
MD5 | c5b39178e78b326dd0222032872ba77b |
|
BLAKE2b-256 | 60629768c9423b9981392cf7a7172260de85bcb06cbe94e31c265db4232d318a |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ed1a20f066e26b60092f9b75997f892ac57618917ab8ee2fd251f36634afcbd |
|
MD5 | 1e51500ed936ba09b83eb57963dc5a23 |
|
BLAKE2b-256 | a575aa050b6a8d18b448e858619706c871401974f7cf311114c1397be9b3c646 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp310-cp310-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2478c186ea68a5506132f8e7bb408e2bf66115de3a57d956e682ed2a0251848 |
|
MD5 | a083f34ee2779a90dc4ec367dafaa528 |
|
BLAKE2b-256 | 8da3b27ffb8b2b36147a81fec7f0df67979dfb364b92134a0b456c53dc5668bd |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp310-cp310-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25acdca026b6e5060bac9bf16b00aebe2afc90c61ed3b9f954feab3139f11917 |
|
MD5 | e4dd90aeb74e7540a82d2851dd4a57c9 |
|
BLAKE2b-256 | 10f248ab748380fe9ce2c47a20f367e0f53f9530f0bdf2bd9d9aaa0078ba0efa |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2cdd339a7946958dcd3f69f9cbc6fdfcd41ce3830ca871a2b08e1fa755a2f70c |
|
MD5 | 5a695450627115db46909bd17c12954e |
|
BLAKE2b-256 | 95723b6ccbeb5b538db3347c79cbfcafcbe07a4eaa38d6f4038548cd858c66e0 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 56bf2f7d9f0cb2fa254e29743ed88f4a5f0a6c62a9944f8e847378a7181a5d33 |
|
MD5 | 2430ab5924b28d08ba36cd10d63711b6 |
|
BLAKE2b-256 | e77bd50905c7b7be45c8a2c0e7c92f136eb3a9439604228c08c02e42e2e93324 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1736b9c3f154d92df6da5d4ae74dda5d223097fa5e086c297c75b1ada8f4660 |
|
MD5 | ee788c8d87b22edfe1e3a7e571a1399f |
|
BLAKE2b-256 | 20de80256af3fc81d07eb66d9d7c5285fd708ed5a838c7141309c0e79e7d469a |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp39-cp39-manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f08956e7f760e4c14909b025355f1dee8f2929945d122d25dca6aa75322c0c14 |
|
MD5 | 2fca554eacd6de7c552f35dbc8f1e9e2 |
|
BLAKE2b-256 | a4449e1541ba249d03f4188dea4127feb692c671b335fb4d7b0fad27f614ce1f |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp39-cp39-manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81a825008a4ade7b0a25028525bad81303948e3bcede1ce0f597f7a28f778a16 |
|
MD5 | ce0ecba9635ecabd7aa84a346e594fb9 |
|
BLAKE2b-256 | a009c73af950335e0b84a8480c049f2bb0160bda1e52579a8af7f1e615a0fb9a |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89889c6cb51a24f7e29eb96277a62ae9e822210cea2156245bd21c1aa1531a33 |
|
MD5 | de50623b4d0219e97d9efba0d5c2ddfb |
|
BLAKE2b-256 | b887d0b94e424096992e3e401bad5254164d55cff864642b7fd48a602049fbe0 |
Hashes for pyAgrum_nightly-1.15.0.9.dev202407281721169663-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c432df0dc7623c2462961b6c24f105544e71579b91fe41942b8abb8f1cc59ea5 |
|
MD5 | da479c92705c7e47b3ba96150082318c |
|
BLAKE2b-256 | 5e19475cec37ea017c47a8c78980cb17e7694c71b49905d57aad56d29b576491 |