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

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

Uploaded CPython 3.12 Windows x86-64

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

Uploaded CPython 3.12 macOS 11.0+ ARM64

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

Uploaded CPython 3.12 macOS 10.9+ x86-64

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 macOS 11.0+ ARM64

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

Uploaded CPython 3.11 macOS 10.9+ x86-64

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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 10.9+ x86-64

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 504fc735319575e072ca9fd97e0c296fb6a500e4925c7fbd436111df07a71911
MD5 b6d9e7b2d8ed66e6c29e005088e012a1
BLAKE2b-256 23dcaa34b017a92392f080ff3061d5215e87e39902b6abadd05705028c83e5f1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 54de67eb5e62836757230143939cbd156e922bec1a73d26eddfee6c42b01b14a
MD5 c42ea8e2b2c279a475f4de016c309b0b
BLAKE2b-256 7f36112b157eaa35e7ca75bc579b28008dd6d3b5f4d91f340da85f47b3342591

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a49989faa29fc065253101a2bec2e7ce1599afd2fb51e5e8151e721c60a52d1a
MD5 1547a585e885e65f9e422b02c9179592
BLAKE2b-256 a44273911af2522f96d38a28e77c5662b8e4b924ee1aaa1b89e7540666379baf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 dd4ea5394f8fd6e39b1d1ab6cd405285f216d0618c1f17a30798d7ae028cc8e6
MD5 ef339cf2da832eeeee8e0dc850923fad
BLAKE2b-256 699e601f2ff3dfd5c909e081ef10829d11d761e260890dd313a74b75380a54e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fd1fe6ef34c8ebe09b9810da86b039eba6289b090c8c1c6b643b6c0ce1922cfb
MD5 f420352406411765b0e2d7ae96d8b654
BLAKE2b-256 f020bed4c65bb698299b9765739d0d15f207ab05e9ed9bc6243b94615ad0eefe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cf9048d0152550c30a423af99080e77217cb7dd79e156bafc1a71a1fda7f589c
MD5 1d95fdb4589aa6464cd42b10c0dbe831
BLAKE2b-256 7e7f152a56516fb62a7b6ed95a5975e895ab478c899776a6c7eac8e7ca6dcbb1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 199647b9e04130d82f056ce8a00c351bd9e104aff9879d38db85bbc886e28571
MD5 2d35b1de146a948c6b6eba97c464600d
BLAKE2b-256 8f00ce2ed4d752aade9f62b499436a143d7110447c24a95f7d5842e244e7e834

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d2d3e24ebe45750b34bbffc7c7ff4420297ec5a515cb9749c14beaaa857b7511
MD5 f68643d42c440b6650b4ccc2fa80064e
BLAKE2b-256 e8cb4b1cae5d625e8dae24662da9586558824ce010bb843532a909c093af357b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8875bbabbb4174c1e2a90e5daa78da4df28e2f3ecbb40348d9c6bb8ba225445e
MD5 4992b05020da4fef853b0864dcafb4da
BLAKE2b-256 e94d835d957a9ce6104f81c3f811aec4ba34f9b3a4b4adb1fbe0f795fcc1223e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 79ef9fce0915a9ddaed31df200d97777c0ddb375f5cde541d33f2c6e8d95aa3f
MD5 9c9586d7f6814efae2fe2bf596ff2693
BLAKE2b-256 7b88a025136e0161f139054ac86aeb38ad1b6b42f4b76d68df36bef7f4171378

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 acc2c94ee43b458bab0a9b06769f7cf504dd0ae11c5889fac259679c377cc789
MD5 2992df44564ea315e8441d009dfaa93e
BLAKE2b-256 1665899d3ceac7a5c2e6afd6f4cd4ea10204dfe6c861f756001db4539f31530c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 917b3ae41176a62ff32051c32b6693541ce943e54371fa52cce38ee59a4c89cb
MD5 a236a2377457416f0a860d26a4180bd5
BLAKE2b-256 7a4fe720e117cddb32c70bb5181ca6e80a417cd325f36475508ebd99890ceefc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 810878c521e342e16c50829f21162f825ebd5ce26d0e239b49c270c871f7f391
MD5 1d61c9d0aaeb49c5a223ec7cd840d845
BLAKE2b-256 cb6019fa8a2b204d399f3395af85f02fb24ae9a71094584314711012158c1b7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d431f58de2d5aeef5b29a0415be428bdd535730a6cd3a6d5ba341f2dce2a469f
MD5 ca0737988864de2a330c191e2bd28cac
BLAKE2b-256 8bb1464489d14fe37d1c59b6bd84d141ce3ff727252bd4c1fbbb930cdb4f842c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202409301727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f3d3a9c0b9e7ed45494d607f8381865f8c4d6d3172f1cc91ecdb22906ca07fce
MD5 d39d522a05abd3c768439956c2f9f4ca
BLAKE2b-256 791b251df5d2278982166d39937ff44c76910227e77a1dbfa9a0093e563619bb

See more details on using hashes here.

Supported by

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