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.14.1.9.dev202407081719384100-cp312-cp312-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.12 Windows x86-64

pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp311-cp311-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.11 Windows x86-64

pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp310-cp310-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.10 Windows x86-64

pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-win_amd64.whl (2.7 MB view details)

Uploaded CPython 3.9 Windows x86-64

pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-macosx_10_9_x86_64.whl (4.8 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 028612ee859eb207786d7995a6434de50fc3a8506e8c3bb156d674bfafb4c9f5
MD5 63c6d293925f031083260e0823c06e37
BLAKE2b-256 2f87346586a54dcd56971be2dd7f59264b8a1ab534a9f7d3904fe043087fb317

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp312-cp312-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b7c40979687beb959a143035b7f3ab616eb7ea32e2195c1151ba74d95921b991
MD5 3579f617d9f2f244876436345e5ac0f9
BLAKE2b-256 f5ecdaf01b1d67898d2ad56c890651f825d1eef17478269ff6c4d3336af51dc0

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp312-cp312-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 5814e7d00e5d86175762416166f48fb47a0aa34e8fc5ac824cc4c33fa8acf67e
MD5 fa2fe5ef8a4919570106f865ea3e1e21
BLAKE2b-256 469b720bda6a416d2af93bb215ab3210321dd9698b2756a7373bb817f743a42c

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ffb7ce7b44cef3f73ebca0e59a1cb470939875a480f3e3f08ec3d8608d0ff17f
MD5 7962e1096496b447d6774beb071c99b5
BLAKE2b-256 0fe3b7d29694aea64e317c3bd4e5eb989cce0251140eba573b8c69f5f1e2f8b8

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 00e6d5fb532944119308bb0c9a74abdfb7fd322461fd89d1a4835539c04bdb28
MD5 10544314890757d09b5a3a1196a2633c
BLAKE2b-256 eb14d2afdc420d7576f7e83d7664359a8fae3dea6c5839532f7e357b2083450b

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5820977708ec6827247775b8c17c875731f71f704193c77b619d33ffd6c8ff92
MD5 f1f99064dbfed2d9b13f7279a84c9cb9
BLAKE2b-256 e55f45524ac194c21de00e97802c031a67cdceacc05358725f41054b7867907a

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp311-cp311-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5e44c480a7428e9b28d9c38641286ba58c15a594f950305dd7c448551f2ecf63
MD5 7a914f1b983855c0cef3777a204a961a
BLAKE2b-256 3718fb5264949f7e106ff44403172be94c880c3d19f6a50d46f19a77daae36fc

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp311-cp311-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 cae17e80f02b7e29a6a85be6f7bef9e6599a60a729443b087ae2ec41c51202eb
MD5 56941dd2be1ef14115d4d9f727b19bcf
BLAKE2b-256 8d750be76fc35841acd2765a13f83ee339396c3eb068cf4e1f750f1dda5645b4

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 aa3b9d90f93fa33b7da611264c70ab316d6a09d22135d59fc2a19f1696fcb33b
MD5 4223fbdb9ae00623567dd56db50fbd8c
BLAKE2b-256 303ea78ef73267f5a7a4491085c84f64e492614d21b10640c3921cc27ae7bf03

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 add70a9fa8c0fdaff457381ad3548579a4483f49da9e99d2aff9e79db9c60154
MD5 c98b782ba39328237fb715e7a7bc7530
BLAKE2b-256 ad2d8dd22b0b2850cbf8eee8a527672c2512c23c24728c7ea3a0d85da43003e1

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 d14f79fd988375a249d152119ee2b439eb20b5b0c51e65aad8a0a1647232d5cc
MD5 6c8aa8616498d9533447882cfaa77b2a
BLAKE2b-256 e6778d31c39566268f8a7247a11eb7f90886719fda63a4170bf47650c71dcbd6

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp310-cp310-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 751e792aea053f0c75c4d533a2957bda7c6735bf515dec6a78aae2e1a4a8409f
MD5 f440f0bd97822107c082aa7b76f196bd
BLAKE2b-256 3759ea0d2114b888faec99a0b2be2cb9f0f0deb2a866f048552faceea7f6507d

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp310-cp310-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 fc0d3df8690e8fe823994f230550864159d6b4b7c38790ddb3217b9c019f257f
MD5 0c0172fcdb43ca1f35526a2cfac7c1f4
BLAKE2b-256 c1e9b3a6e83918d80d980cf4be27aff6ac4bda7a749e2ba98cbcbbbed5029833

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7b66aea8bb2380d434ee7a9f4ffc410f676ca83c6101d897ea5ff66eb67f657e
MD5 be8d4f07fefb6c8a0a32d1020b9d2f81
BLAKE2b-256 c1839669d6204d31105faedb540b8fcb420153236076dcd834c47848e8c8c159

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 af29c5a1938274cd2ca521f7429326c03ab3dab9de4ce453053bffdacb8fcd87
MD5 2c33c04df493fd4203ebf1cf570c1efd
BLAKE2b-256 f3012e03c2dea447126e584d2ab12fb04b62026f84b4e36a07575ea5a304727e

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 626eaa4bf88ff2c9617acabc238adb9806e6233a35ab371d53292ee4986cf8e4
MD5 c97dedd85897d2b95b1d7d0335db9301
BLAKE2b-256 3b1eedcc0b8824b885f7b1724f66dd627055629be854c3cfafd7d809ba10bcac

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7ad668962f5df053b83b48fe43c507dd0627a659a356eb1475124e0cf38df16c
MD5 b5d58e7102299803ac9517c2410bb640
BLAKE2b-256 d88feb5f70f77cdf2a978ebcdb947e3e1b5b4579c1ee1c1b5e3158a8690768c9

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 07513fa22bcbe12b5b14df72634afb4153ddbd9423ef32011d4f5c20076fde3b
MD5 551713ccfe71a8bdc403304673534bce
BLAKE2b-256 74f3c284d49bc2e4ff1c206f418a3c02ee8d946bcdb4db86a0bf94aed5f843b7

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 33e69ab4d65a32b06e272902e94f95dc88fb81f3e6ce766089ae8255c8505e11
MD5 58226d8a3d152c8f382c3b5f1b0d9f20
BLAKE2b-256 28a07015b25bf69f6cd611d0e8661bb8213382e7acd7891e1bf85c43253570ce

See more details on using hashes here.

File details

Details for the file pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.14.1.9.dev202407081719384100-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cb85269aa043680d0117fd2de00d663bd5ea92e1b2641e6149cf562b159275ae
MD5 8c06bd14d5e270ca2dc9a5979ae16a5a
BLAKE2b-256 d6c18a20bfc5da71460ac9648b1f868e1ec6481d98db3bde5b1922974d344921

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