Sign inSign up

agrumery/pyagrum-notebook

By agrumery

•Updated 3 days ago

Image
0

2.0K

agrumery/pyagrum-notebook repository overview

This image is based on https://quay.io/repository/jupyter/scipy-notebook⁠, you can check jupyter's documentation on how to use this image.

If you are in a hurry the following command should work:

docker run -p 8888:8888 agrumery/pyagrum-notebook

⁠pyAgrum

aGrUM is a C++ library for graphical models. It is designed for easily building applications using graphical models such as Bayesian networks, influence diagrams, decision trees, GAI networks or Markov decision processes. pyAgrum 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.

Since pyAgrum 2.0.0, the package name follows PEP8 rules and is now pyagrum (lowercase).

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-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 dual LGPLv3+MIT license, see LICENSE.LGPL and LICENSE.MIT.

You can therefore integrate this library into your software solution but it will remain covered by either the LGPL v.3 license or the MIT license or, as aGrUM itself, by the dual LGPLv3+MIT license at your convenience. If you wish to integrate the aGrUM library into your product without being affected by this license, please contact us ([email protected]⁠).

This library depends on different third-party codes. See src/aGrUM/tools/externals for specific COPYING and explicit permission of the authors, if needed.

If you use aGrUM/pyAgrum as a dependency of your own project, you are not contaminated by the GPL license of some of these third-party codes as long as you use only their aGrUM/pyAgrum interfaces and not their native interfaces.

⁠Authors

  • Pierre-Henri Wuillemin
  • Christophe Gonzales

⁠Maintainers

  • Lionel Torti
  • Gaspard Ducamp

Tag summary

Content type

Image

Digest

sha256:cbc402212…

Size

1.6 GB

Last updated

3 days ago

docker pull agrumery/pyagrum-notebook