Skip to main content

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.

Authors

  • Pierre-Henri Wuillemin

  • Christophe Gonzales

Maintainers

  • Lionel Torti

  • Gaspard Ducamp

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.12Windows x86-64

pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.11Windows x86-64

pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.10Windows x86-64

pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a366680c95d78d8774f5d201b5d4bb504fb4af2ec30dfc6407420e801fd38219
MD5 81368ba0ab941133b1119daac8ce6f5d
BLAKE2b-256 bb9cbb0ceb83420087e73d9c9dd8d57c99bde4ef0631d9d13c96aab541887fef

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 08ada94d4ec8246eef83ace7e6ff621f86f9e51bded4355e5fa57b893b28951b
MD5 df7112c8a0fb2c3e787590d20a8aa346
BLAKE2b-256 4857bb134fb7ffeb2b8e60b1eed6715668339ec9c45c006cc0a2f65699928acf

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 1ca130ca6ef34f3855a685273646262e0e4bb527f0d013747ff697141af314da
MD5 c152da1d23ca6abca4996d382ecdc3b9
BLAKE2b-256 b88ea1dd7348f6adecb09946cf85a1ef4d5bc1bb7996b0ec736dc0a5521e12f2

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6e86a89769f3fb5106feb189f257682a5a74f11965621da777f2ba6564bbec3c
MD5 331cf9abfd3b473b587479552f163ea1
BLAKE2b-256 8d0abf0f3c64d9648c14363b67a16f8edd82348ff8ccd5c037612decc0967438

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1a110f7eb21bc7b3126fd292a061ec94f01e7d6a17cae084744ab9c9dacd39ae
MD5 d343fda2d5c5a40f33b0ebbab5f33fda
BLAKE2b-256 7806e80209d9a33558c2b7054c83c23cad56716d46f1a6f41880d3470af7d95c

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 560f283a8725fc914ae8a20905acef079886fd92b4c4734b41d7045feaa762fb
MD5 2093f46d57005436c1568ce6eee84bc0
BLAKE2b-256 6100465347f71eaec7b7369626e21bd7b4cf65d01a57d59545aee8dffb274ae7

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 085c3ccab3e34cc4436689f0f2385ee1aab90da68de8128537f7eca354f80464
MD5 9bd9fd86b55dcd54359c91364aa5d0a1
BLAKE2b-256 a7825b63e175415ad4842b66df0aff422e6293618d557040e527fd47ef5f7608

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 87bafc1b85f789a63927dfe72962171a18d813346140ed304250b74c23b316fa
MD5 62d22a2d5ad824d189da5e376d4546c9
BLAKE2b-256 939ba961470ec477d84a9827118d30abc437881f8bcf63b72ca241b5131884cf

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 666e0940a910b9368e13a80b68bd9f9971f431613e639d77fce883fc07a7efe2
MD5 0d72408cb1e16328d889951d8a0d68c2
BLAKE2b-256 b64d736a78d6bd9ae3509dc25387c731583e6def7243be7835140b047bdb88b6

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 25091d0532976e1de7dc7c9a24a5991b14770930c949f30bd92b0790c9bf27bc
MD5 527e15823934a3cdf022d76424461ff0
BLAKE2b-256 b19f8c14e475ed67a7b70119246cbc3c50ae32a7d870437ca4c4b523ae1d0c43

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ecc40f5d170d899a87ff0732ad189d64e1ffdbdb72b23a761272dcf7c20ef347
MD5 5de01eeb6a6ac2264266b563b832bfff
BLAKE2b-256 52421b79a79244a8078238b6f01c16ef05bb390a31b1524bf9084a203e0473de

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9fcbd22491eb79be4e64170d6e82b42a4d210bf787d09fc7aacde7f550883e4b
MD5 556001337fb2b1888981b74a074b911c
BLAKE2b-256 11189c804713c6220e46e83ab5c54d6d91d6d44eff12dd9e05b5964b631ab3d5

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dffd4657cbe94755211da10977bae80e170a227b07904d72fa0a753b99749699
MD5 37f02fb3169d6203662ca65e3d7c6c52
BLAKE2b-256 8408a79f344714a30c1c2ac6ea6f29b146d5a9bcf16e534441e7a576bfd664ed

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1f33f89312c0539ee1dd3282f47d96b7f29a8bb5f8aca2e137fcc5fe0f9df6f9
MD5 b2f2348fb4a86fb98f54982a40c15253
BLAKE2b-256 2c65a84dbbab859b7ce946eacb362916e0848c91458819bb55da1b938010bdef

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410121727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 777434b2a486f312ecab1db00a3f06a95134895101becdb6e2d5a9d8a12b857d
MD5 995743d431f1701b214e5ab6f16e6a29
BLAKE2b-256 bc0c444c4279bfdcfa5f78580ab2aa3f2e59b768e8dbdd6495fe7f34459240a4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page