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.17.2.dev202412241731932516-cp313-cp313-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

pyAgrum_nightly-1.17.2.dev202412241731932516-cp313-cp313-macosx_10_13_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.12Windows x86-64

pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.12macOS 10.9+ x86-64

pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.11Windows x86-64

pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.10Windows x86-64

pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-macosx_11_0_arm64.whl (4.3 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyAgrum_nightly-1.17.2.dev202412241731932516-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.17.2.dev202412241731932516-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 23e5eb0b09643add7621dbd31d14c899b7c3d977a1bdeb0f688ed012fbaf883b
MD5 f1d242dffb18a53082e48fa53bf9634f
BLAKE2b-256 bc1355f8627ed33075c9b59d3789564cf36cfd2baf5ec4fd7f479a1c7115ac7d

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 b472987fc9f40f107807a52b3e7aeba02fd1f5864f817b2cd1d73193d16ddbfc
MD5 84b217efe0bf6b85db3ab87a674b984f
BLAKE2b-256 82b8ace9a008a32498e85ee2e137cfd8f98c052b5007581e71516591e08c70dc

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 4f774d9e98713303d296b95b7977b353c6b7101526952fdfb7663427bde0d9a6
MD5 e07d74752a40f9dd6b4f60d4f40debca
BLAKE2b-256 3c980ba07b3a05ab94d99fd4776424b6d8acfabf999e35889cf9cc2365ed0e17

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b51b42cdea648ec720e1b26863ee253a7993acbd631fc858331ca50394d4a060
MD5 41f6f9f943d21e41f9ec37f1ccd93ab0
BLAKE2b-256 d5d2c505ec643da76d400b21d300b2140aa701ed6d84c97e18c4135b8cef0a68

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 919aa2f6c350183dfeed4f8eccd45ffc5d82169e0eacf6cc033001ad80e5d7a1
MD5 4dcd1b24c4d9093ef057532c8b9aeaad
BLAKE2b-256 ba2ffcc1224727f0f464db725f12a99a48b79c8f6f39279c4eb67b08299ac34d

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 74cee2518738e1bc967d0f4785be3ecca0313bae0084daaf3942bde80be727bc
MD5 704f2aca0aeff6a2bfccb83957c49fe5
BLAKE2b-256 a0dd35414293741ef01bbb0884d1a0dc600a3552828ba66202e1c8f2b2c2a36c

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fe308380bbb03a62239696bea7e744f5f06280bdad996813d9be024d2d29ad49
MD5 b873829d43609ce633855937a8a84637
BLAKE2b-256 51a257307738aca7ffc6e8e5e26ef49d7dcf35d277612d217c0cab4b0b86600f

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 4c9b09973f72e75dc69daa09370306e8756c3546f03fe7183e7d2832d4e65e42
MD5 3692eb4cc2dc07a407fdce332d0e2230
BLAKE2b-256 1e2e25a1f844b882f6e13617b27b63f87444334bddebfd2e84e4e220e77fde43

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5eb464170bc550eeb433d154b80277b9c8c8cdce538ea3465034dfc275f4a0f3
MD5 be00e28ee264c19fdac5d951960051b7
BLAKE2b-256 e62b7361640ad67f35364b8348afaa62cf547068509390adde0055db40571cc0

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 54b3ecf0ca88f6bef4d93bdae46919d5a0c9bee18ce2729797af2738d889fe35
MD5 6e60d8a0fcf922884ab7f96c0734fad6
BLAKE2b-256 9fc1d4e41f32a58994e356dcc276b911213b479afd14014f4bc8081e731a2ce7

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26f4dd22e1e59e35589da1c2e37e31b69017e6c1b2463d958e629463cfb4961e
MD5 4e6fff120841eab3b4d3bff820703591
BLAKE2b-256 4b097a67e103cc2b8d190ffc000b461bcffde28235f5e36add450c828c656fb2

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d81267815f875b2cbd3ae71735649996455116f74e86be622d77562a501297a9
MD5 0fe4c1d12ac39035b68ab0489031f770
BLAKE2b-256 aeea89e2aff0556535b5b6037d028b8954605b19aa6c4cd7caa33ededecf9080

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4b895428f07378e510b4d0fd2937bbc445b906e5c1e0f0a6dae76ba140dd0738
MD5 79838c9c32af330e02a48b9100abf724
BLAKE2b-256 a5a68c4228aac5cef277dfadaa9fdc8a31d2f3f706445b214ed09b0b2259581c

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5ac4af1de7cd2508eb963bdc74c9043b65041ceeb2b679a04768fb25a9d7f196
MD5 44f3d5e6c4b7650818b868c1492d253b
BLAKE2b-256 8c2f777de1325368c2946a84402e4348df5639e5f21336449f4fdf1e88c9ec96

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 75a432fe7209242df29b606a4b48d3b9e1142dabfde022ced1a0e56ee9ee6d77
MD5 fb839d2fbd8e841e4dd5f94a04e22358
BLAKE2b-256 8bdd4888509209f90bf6ad625e1924aab87fd8e7281d6965610925ded1cc790d

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7d6a27031b88a3934f419c0c079f2a87078d8bb4f6a98f56bf0481fc0791b2f5
MD5 0efc95df068911b6ff03e45c30e97f16
BLAKE2b-256 3aa7912b0df18a0099d206547488cc27bedbc894e987ec95138c6b8b9edc5253

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.17.2.dev202412241731932516-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7c4a3bf8c2c71768942374063d345c22d25b75a521769a7f04dae23e02398e9b
MD5 83e8053e33e3f3aa8874c391e7276138
BLAKE2b-256 2fad5d6e400db2f595bbda81521bdbba20d3f9edd334843479e530d574c30e41

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