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.dev202410071727562243-cp312-cp312-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.12Windows x86-64

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

Uploaded CPython 3.12macOS 11.0+ ARM64

pyAgrum_nightly-1.16.0.dev202410071727562243-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.dev202410071727562243-cp311-cp311-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.11Windows x86-64

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

Uploaded CPython 3.11macOS 11.0+ ARM64

pyAgrum_nightly-1.16.0.dev202410071727562243-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.dev202410071727562243-cp310-cp310-win_amd64.whl (2.8 MB view details)

Uploaded CPython 3.10Windows x86-64

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

Uploaded CPython 3.10macOS 11.0+ ARM64

pyAgrum_nightly-1.16.0.dev202410071727562243-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.dev202410071727562243-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 974a14748d267c1e3408de7e3203a596af43d7b68abaa01aa8b86bf9f514eb4b
MD5 c95ac70e15730cc01e6e1ca063510370
BLAKE2b-256 146dd764cff8aedaab23b8d6d02c037c7007d6760f5d4b8ad436a648fbccbbf7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp312-cp312-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ab33b5d02cc616a8c58aa29b87b697059ba6ae0d40d9794404eeef33b5b80408
MD5 be7eb580d26419b2f37bb0dce1bea3c2
BLAKE2b-256 9335cea75f6aefeaeddf38f33256e3754ae647b99a0409fe0fffac8e8c72131c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp312-cp312-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 9e8214dfce5bfb1cb34c7d23fcac6397ebb3086debca122b224b3825e0a02003
MD5 0b0a51f11ebddcc7d79e62d3d9b0d868
BLAKE2b-256 6f25e73503e7b4df0e71827872a8bdd19d1ea28debb407da0345687d6c005787

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 f1785c7f5df4032cb53595fa123135e6be0a86634233705bd8870830fd83ec09
MD5 8e13c7d32d2d449518404ca9537dd327
BLAKE2b-256 87ff05e4790f5187359004f9b7b031dc28a66778b7ab4cb71cd9d88a26d528e3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e145fcf57d5c06027bf5a7004f14937786c85d956e45c7f9b12f4b087dbf8829
MD5 10d30228362d2e47d156b081d9565051
BLAKE2b-256 d925bfd61a401e404f505a946bcb3fbf4a690fd3cd9b36f72f526293373a7a3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8c80ee789ac3704857cde34d6a39623b73d2f29a59534db0fdacf802552a6496
MD5 0881c122ce33f759214b038fb19c64f3
BLAKE2b-256 653988513506b3e76c69f1b925c8ddc44a43bb610e3c92c52b0bc3a75de58fa6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp311-cp311-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb3e55eef4a4cad02060b30d52c68fd9ff3baaee0ca878762b07332600709e81
MD5 13d6ac93a9d4b84c0bc93ccfc54ec209
BLAKE2b-256 05fa0596d77569d60088b58b5f7c6b00f60719583b5c98012232e8062d1b7c78

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp311-cp311-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 2fbedcb9a471b62975526231e0bc107ae99844688683f4696c76f80a27e3a11c
MD5 0371d54fa039d5915bc6c04c73049928
BLAKE2b-256 056366fb3eff83e4319567c3fe9c03b30d993972e5dd0a1a22a67c542f993801

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 11ee6dd20c107974db7707b548254fc73a5e524eb657c7d0ce62ab923335b769
MD5 28d21f829d29c6a3f432f87300c0863b
BLAKE2b-256 7a2fe5f4e187793b5f2f92224174dd9a28b23b6795ed2517cdd7c403f3dfccca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ada4083821eb15689c2c9801f1756aa12205342969c3358cdca697dc2ca2016c
MD5 529a015920e03e523b8d1172a482615c
BLAKE2b-256 d1db9dbdbfc55af22295e7b2cf4fabf4b4c0f19ece3a72d733dff035459eb87b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 db7c44ee1377950c4fee6df47d67d7ead2aba27a0293b3e5760ef0ab25946ca8
MD5 2e35242f561aadda02b6faa1f0bb8543
BLAKE2b-256 3c795d44b71ee5ed1f155201076979dd1c202d1eea6e78834e28c089de8b794d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp310-cp310-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2ab1ff4a25fd090cc842bcbc3240793ad223f7f2c34087d003276af5bca3fc44
MD5 7f5fe5709106e5d26d23b4fe2ccceb7c
BLAKE2b-256 b5551171db592665df72f0cccb5c4bd334b9346db095421511685dd1c878251e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp310-cp310-manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0faaceeff2741d9bcb228fd540292d768b13c65e7bdeb9c7b0252e470406da2f
MD5 5a555c5fb5685ff4056690a648b028cc
BLAKE2b-256 61111c774b40b850bc536cf51cd5c8ad63600dd35bb531646f999b781d445078

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b92807c3a7859b59dc58e92d1101aba1bbf6e658368be4ac2aee945e576ef6b3
MD5 7ba022cd14c6d0a32c0c501d6b513340
BLAKE2b-256 3912d34f5aaa8fc0236c905d0f470b52486c38d7014949bf0af714de666f4145

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pyAgrum_nightly-1.16.0.dev202410071727562243-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e16cfe1e793f8eb0efaab2888e5339b9d0f215361ad0ae287ae7bb1ad2cdff40
MD5 843d6e292a5722db8a23ab505d358ebb
BLAKE2b-256 8f19260f948a65cca6ad1458733f0ca23fb99c18fe1175fd219496ace5d6568a

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