pyAgrum is a Python wrapper for the C++ aGrUM library
Project description
pyAgrum
pyAgrum is a Python wrapper for the Agrum library, to make flexible and scalable probabilistic graphical models for inference and diagnosis.
Sample code:
import pyAgrum as gum
bn=gum.BayesNet('WaterSprinkler')
print(bn)
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 ?',2))
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)
# 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)[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)[1,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 evidence
ie.setEvidence({'s': 1, 'c': 0})
ie.makeInference()
print(ie.posterior(w))
ie.setEvidence({'s': [0, 1], 'c': [1, 0]})
ie.makeInference()
print(ie.posterior(w))
LICENSE
Copyright (C) 2005 by Pierre-Henri WUILLEMIN et Christophe GONZALES {prenom.nom}_at_lip6.fr
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Maintainers
Lionel Torti
Project details
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
Built Distributions
Hashes for pyAgrum-0.12.0.9.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 927e4dd5c0be6cf2c9323df9080ec55259a5f5d3d522da0fad1aed992a88ed28 |
|
MD5 | 8ae20b05888ec81b0978b9bb81b8d2b5 |
|
BLAKE2b-256 | 0e6c611872a21b3d37bc7690131d0c3a500c4743a856d5f3c030370a58d29896 |
Hashes for pyAgrum-0.12.0.9.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 006f52796e88b4e3a47720c41229a08af0c29a567e5ee8ee4e1fc4adf9a60077 |
|
MD5 | 62dc4fb82bd514184cfe200855c0e38d |
|
BLAKE2b-256 | ceb09966623c4130a6bb710470890354fb226d2200c2284c0676fc24ebdb0852 |
Hashes for pyAgrum-0.12.0.9.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ab9589c9e62b3797e149d407eb334b3c61f8e9286db36a436b6db08381b7047 |
|
MD5 | f8c2b722463dc37cf6a7e8ef6417b985 |
|
BLAKE2b-256 | f0e28d307e216fb1704579c4dec0fd45e700116766075cae8b863084cca326d9 |
Hashes for pyAgrum-0.12.0.9.1-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1119f46077a88af89578db90a5685a4075714e2e7ee0427fa9237a9c6f5f9b32 |
|
MD5 | 925e0a8c5d23c6b83009ae9b0c7bb7df |
|
BLAKE2b-256 | 6582d0b4308136ef07e2fe03850911ee8b55f172ba3a59d8b361138709c890d9 |
Hashes for pyAgrum-0.12.0.9.1-cp36-cp36m-macosx_10_13_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af6966a9926be964eb4cb18b9a34b86d9b383ac15c17257f186b5e2b962a6335 |
|
MD5 | 3fedaadac194645d3e02111fc66db5d2 |
|
BLAKE2b-256 | 13eea956d65dd44653060d437b8be875efd19b8595fa148c41cba180e80c4bcd |
Hashes for pyAgrum-0.12.0.9.1-cp35-cp35m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 024e256ad356136e7dad111a8cfd4ea7338fadad54e8cc3c559fe671f4cfbe3f |
|
MD5 | 7ec46f4e49ed8eedf7b83ede35c58730 |
|
BLAKE2b-256 | 965c99c8552794e07dc4bd742a9aabc94b42dd931f1b36bdb232af3cc68e915f |
Hashes for pyAgrum-0.12.0.9.1-cp35-cp35m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49b3b213290289d331926b371dc5509b1bb67000cf06818f5300c126c37d5350 |
|
MD5 | aac7ec03a78223316e00ad66d82d9997 |
|
BLAKE2b-256 | 5a325db051c5fdb1fb5e2fe74b6337e30a0c39515164feb730888856224c079c |
Hashes for pyAgrum-0.12.0.9.1-cp34-cp34m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 002592a99ffb0777218f34e777103862c5e7ed22f249c998a0e349200a5b7e28 |
|
MD5 | d0e0dbf46f87733030da36c2c7be3bc4 |
|
BLAKE2b-256 | 413930089a9eb0f595d46c8ad9f1b274b255120c1849399f6bb658a1ded4834f |
Hashes for pyAgrum-0.12.0.9.1-cp34-cp34m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43bf9b54fa70a536109b07277ba7454fa766e87c04666acbd00c1928debb6e3a |
|
MD5 | 18ea66441b018e27130f207bd24589ec |
|
BLAKE2b-256 | 4cd3dcbd4dd7d44ab01b0af0bed00dd05361431ec42f2557ad5c18edbed65587 |
Hashes for pyAgrum-0.12.0.9.1-cp33-cp33m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9eb0f9e6a491c23f3a5766eeb9e8d04d8ed773cf9e7745ea32ee6842da33853f |
|
MD5 | c758336810c5e27c1b2bc4f8c1070486 |
|
BLAKE2b-256 | 385961c115562e23f53b587d7e5fbf36b8a3f8398aaa1e5b7e8c424c35aee9b5 |
Hashes for pyAgrum-0.12.0.9.1-cp33-cp33m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f40ca25f54bb56a0d284251c6673be26ce0692f757b08a3d484668b8ab5ce80c |
|
MD5 | b955706b295c44471478233b65c21999 |
|
BLAKE2b-256 | bf326842aa67ef5710c1cb0d2b38cac4580004d74f888043b592fe4de2aa8d46 |
Hashes for pyAgrum-0.12.0.9.1-cp27-cp27mu-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df9a9baf74ccd7465a2b369cf29984f534163720a0390d6a45e9a081a508bbf4 |
|
MD5 | 3bcd821eeef33cfb8e13a55cffcdc0b2 |
|
BLAKE2b-256 | 9cfa1f64b6556b85709d33a7cfafe8e979cfc4b2431b7782c21273109d099a12 |
Hashes for pyAgrum-0.12.0.9.1-cp27-cp27mu-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbf0ce153cc0b0893ec434dc8cdf2c9cf7ef2e892f66eb3488aabcae8a48bdd0 |
|
MD5 | 616c3d553dc21a2a4de67461a1a20cde |
|
BLAKE2b-256 | 1bd2b675f8b1454fea55b11f6c7b7bd1fcd1dc498c91ee99a81e5c9bf8c9cf67 |
Hashes for pyAgrum-0.12.0.9.1-cp27-cp27m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79848e8a36955dedd82b91907828c01cc533b6e0acb731e6cee2e5ae9912ca5c |
|
MD5 | 1320f7539a769b422d94715646e9df17 |
|
BLAKE2b-256 | 4a4e047835e469e43d7d7de24746761049663a698fc0f2ddcdc66157ae8ed6e4 |
Hashes for pyAgrum-0.12.0.9.1-cp27-cp27m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b77071d5b32bc719051c90d506337b0c8b8466d324634679eab01793b8ecd2e4 |
|
MD5 | c8cb6e53d1dc147bdcb14f9648bee822 |
|
BLAKE2b-256 | e7adff5b3ed9519223784367ae0f93c264d1bc45d21eb26b92ea508635bff610 |
Hashes for pyAgrum-0.12.0.9.1-cp27-cp27m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77499482d012302ae6e246ccd63ff8e3c5715c332f8d182d7679559c06949a38 |
|
MD5 | 057f95d4f86b0f12fc6f3cc3792104fc |
|
BLAKE2b-256 | 5d1206fc88ec6aa804a1255232e9e262185e583f172fae26e94aa872e3cc6ba6 |
Hashes for pyAgrum-0.12.0.9.1-cp27-cp27m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b5e91946e780740622b949b6e8b26ceb024ffb4f429630079c4e480d96f2ce1 |
|
MD5 | cb238eb617a126566d516a311ae363d3 |
|
BLAKE2b-256 | 550f17dd42139398ec05f102d1ae49b3fbbf8e38a6426d0d7971aa1687b30461 |
Hashes for pyAgrum-0.12.0.9.1-cp27-cp27m-macosx_10_13_intel.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b401f451c500c77224910d45cb7864da29d215e3521dfcca17b0f2469c30c50 |
|
MD5 | 23e7253b2e641ba4d00362f155d4df35 |
|
BLAKE2b-256 | a18c71dab038a8996101fadb16fae0a63b044794860ced57b3efe0bd177142be |