3. Python Code

3.1. Network

class py2GeNIe.Network(name)[source]

Bayesian Network

Attributes :
  • name (str): Name of the network
addNode(node)[source]

Add one node to the network

Args :
  • node (Node): Node element
addNodes(nodes)[source]

Add a list of nodes to the network

Args :
  • nodes (list): A list of Node elements
writeFile(filename=None)[source]

Write an output file

Args :
  • filename (str): Name of the outputfile, If no name is defined the name of the network will be used.
Returns :
  • outputfile: The output files is saved in the local folder.
Raises :
  • Error: No nodes connected to the network!

  • Error: Node ‘xy’ has no outcomes!

  • Error: Probabilities for ‘xy’ doesn’t match!

    Len of probabilities should be a but is b

  • Error: Probabilities for ‘xy’ doesn’t sum up to 1.0!

3.2. Node

class py2GeNIe.Node(name)[source]

Node element for the Bayesian Network

Attributes :
  • name (str): Name of the node
addOutcome(name)[source]

Add one outcome to the node

Args :
  • name (str): Name of the outcome
addOutcomes(names)[source]

Add a list of outcomes to the node

Args :
  • names (list): A list of names for the outcomes
bar_active = None

View as Bar Chart

Default :
  • False: i.e. GeNIe will show Icons instead Bar Charts by default
getOutcomes()[source]

Returns a list of outcomes

Returns :
  • outcomes (list): Returns a list of outcomes
getProbabilities()[source]

Returns a list of probabilities

Returns :
  • probabilities (list): Returns a list of probabilities
getProbability(index)[source]

Returns a single probabilitiy

Args :
  • index (int): Position in the list of probabilities
Returns :
  • probabilitiy (float): Returns a single probabilitiy out of the list of probabilities
getTableSize()[source]

Returns the size of the probability table

Retunrs :
  • m,n (tuple): m represents the rows (number of outcomes)

    n represents the columns (depending from the parents and their outcomes)

setBarActive(bar_active)[source]

View node as Icon or Bar Chart

Args :
  • bar_active (boolean): True for Bar Chart view

    False for Icon view

setFontColor(font_color)[source]

Set font color

Args :
  • font_color (str): Font color given as hex string
Example :
>>>
# red: rgb(255, 0, 0) -> ff0000
xy.setFontColor('ff0000')
setFontName(font_name)[source]

Set font name

Args :
  • font_name (str): Type of font, e.g. ‘Arial’, ‘Times New Roman’
setFontSize(font_size)[source]

Set font size

Args :
  • font_size (int): Size of font, e.g. 8, 12, ...
setInteriorColor(interior_color)[source]

Set interior color

Args :
  • interior_color (str): Interior color given as hex string
Example :
>>>
# red: rgb(255, 0, 0) -> ff0000
xy.setInteriorColor('ff0000')
setNodePosition(x, y)[source]

Set position of the node

Args :
  • x (int): Position in x direction
  • y (int): Position in y direction
setNodeSize(x, y)[source]

Set size of the node

Args :
  • x (int): Size in x direction
  • y (int): Size in y direction
setOutlineColor(outline_color)[source]

Set outline color

Args :
  • outline_color (str): Outline color given as hex string
Example :
>>>
# red: rgb(255, 0, 0) -> ff0000
xy.setOutlineColor('ff0000')
setProbabilities(probabilities)[source]

Set the pobabilities for the node

The order of these probabilities is given by considering the state of the first parent of the node as the most significant coordinate, then the second parent, then the third (and so on), and finally considering the coordinate of the node itself as the least significant one.

Args :
  • probabilities (list): A list of probabilities for the node

3.3. Arc

class py2GeNIe.Arc(from_node, to_node)[source]

Arc between two nodes

Attributes :
  • from_node (Node): Node where the arc starts
  • to_node (Node): Node where the arc points

Table Of Contents

Previous topic

2. Tutorial

This Page