PyCTBN.PyCTBN.structure_graph package

Submodules

PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix module

class PyCTBN.PyCTBN.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix(state_residence_times: Optional[numpy.array] = None, state_transition_matrix: Optional[numpy.array] = None, cim: Optional[numpy.array] = None)

Bases: object

Abstracts the Conditional Intesity matrix of a node as aggregation of the state residence times vector and state transition matrix and the actual CIM matrix.

Parameters
  • state_residence_times (numpy.array) – state residence times vector

  • state_transition_matrix (numpy.ndArray) – the transitions count matrix

_cim

the actual cim of the node

property cim: numpy.ndarray
compute_cim_coefficients()None

Compute the coefficients of the matrix _cim by using the following equality q_xx’ = M[x, x’] / T[x]. The class member _cim will contain the computed cim

property state_residence_times: numpy.ndarray
property state_transition_matrix: numpy.ndarray

PyCTBN.PyCTBN.structure_graph.network_generator module

class PyCTBN.PyCTBN.structure_graph.network_generator.NetworkGenerator(labels, vals)

Bases: object

Provides the methods to generate a network graph and the CIMs related to it Items in _labels, _vals and _indxs are related, and therefore respect the same order

Parameters
  • _labels (List) – List of variables labels that will be part of the network

  • _vals (List) – List of cardinalities of the variables in network (defined in the same order as _labels)

  • _indxs (List) – List of the nodes indexes

  • _cims (Dict) – It contains, for each variable label (the key), the SetOfCims object related to it

  • _graph (NetworkGraph) – The NetworkGraph object representing the generated structure

property cims: dict
property dyn_str: list
generate_cims(min_val, max_val)
For each node, generate the corresponding SetOfCims. The objective is to group the CIMs

(actually generated by private method __generate_cim) according to parents possibles states of every node. This method must obviously be executed after the graph has been generated.

Parameters
  • min_val (float) – Minimum value allowed for the coefficients in the CIMs

  • max_val (float) – Maximum value allowed for the coefficients in the CIMs

generate_graph(density, fixed: bool = False)
Generate the edges according to specified density, and then instantiate the NetworkGraph object

to represent the network

Parameters
  • density (float) – Probability of an edge between two nodes to exist

  • fixed (bool) – Specifies whether the required density is mandatory or it’s just a probability

property graph: PyCTBN.PyCTBN.structure_graph.network_graph.NetworkGraph
property variables: list