classes.structure_graph package

Submodules

classes.structure_graph.abstract_sample_path module

class classes.structure_graph.abstract_sample_path.AbstractSamplePath(importer: utility.abstract_importer.AbstractImporter)

Bases: abc.ABC

abstract build_structure()

Builds the Structure object that aggregates all the infos about the net. Assigns the Structure object to the instance attribuite _structure Parameters:

void

Returns:

void

abstract build_trajectories()

Builds the Trajectory object that will contain all the trajectories. Assigns the Trajectoriy object to the instance attribute _trajectories Clears all the unused dataframes in Importer Object

Parameters:

void

Returns:

void

classes.structure_graph.conditional_intensity_matrix module

class classes.structure_graph.conditional_intensity_matrix.ConditionalIntensityMatrix(state_residence_times: numpy.array, state_transition_matrix: numpy.array)

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
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
property state_transition_matrix

classes.structure_graph.network_graph module

class classes.structure_graph.network_graph.NetworkGraph(graph_struct: classes.structure_graph.structure.Structure)

Bases: object

Abstracts the infos contained in the Structure class in the form of a directed graph. Has the task of creating all the necessary filtering and indexing structures for parameters estimation

Parameters

graph_struct (Structure) – the Structure object from which infos about the net will be extracted

_graph

directed graph

_aggregated_info_about_nodes_parents

a structure that contains all the necessary infos about every parents of the node of which all the indexing and filtering structures will be constructed.

_time_scalar_indexing_structure

the indexing structure for state res time estimation

_transition_scalar_indexing_structure

the indexing structure for transition computation

_time_filtering

the columns filtering structure used in the computation of the state res times

_transition_filtering

the columns filtering structure used in the computation of the transition from one state to another

_p_combs_structure

all the possible parents states combination for the node of interest

add_edges(list_of_edges: List) → None

Add the edges to the _graph contained in the list list_of_edges.

Parameters

list_of_edges (List) – the list containing of tuples containing the edges

add_nodes(list_of_nodes: List) → None

Adds the nodes to the _graph contained in the list of nodes list_of_nodes. Sets all the properties that identify a nodes (index, positional index, cardinality)

Parameters

list_of_nodes (List) – the nodes to add to _graph

static build_p_comb_structure_for_a_node(parents_values: List) → numpy.ndarray

Builds the combinatorial structure that contains the combinations of all the values contained in parents_values.

Parameters

parents_values (List) – the cardinalities of the nodes

Returns

A numpy matrix containing a grid of the combinations

Return type

numpy.ndArray

static build_time_columns_filtering_for_a_node(node_indx: int, p_indxs: List) → numpy.ndarray

Builds the necessary structure to filter the desired columns indicated by node_indx and p_indxs in the dataset. This structute will be used in the computation of the state res times. :param node_indx: the index of the node :type node_indx: int :param p_indxs: the indexes of the node’s parents :type p_indxs: List :return: The filtering structure for times estimation :rtype: numpy.ndArray

static build_time_scalar_indexing_structure_for_a_node(node_states: int, parents_vals: List) → numpy.ndarray

Builds an indexing structure for the computation of state residence times values.

Parameters
  • node_states (int) – the node cardinality

  • parents_vals (List) – the caridinalites of the node’s parents

Returns

The time indexing structure

Return type

numpy.ndArray

static build_transition_filtering_for_a_node(node_indx: int, p_indxs: List, nodes_number: int) → numpy.ndarray

Builds the necessary structure to filter the desired columns indicated by node_indx and p_indxs in the dataset. This structure will be used in the computation of the state transitions values. :param node_indx: the index of the node :type node_indx: int :param p_indxs: the indexes of the node’s parents :type p_indxs: List :param nodes_number: the total number of nodes in the dataset :type nodes_number: int :return: The filtering structure for transitions estimation :rtype: numpy.ndArray

static build_transition_scalar_indexing_structure_for_a_node(node_states_number: int, parents_vals: List) → numpy.ndarray

Builds an indexing structure for the computation of state transitions values.

Parameters
  • node_states_number (int) – the node cardinality

  • parents_vals (List) – the caridinalites of the node’s parents

Returns

The transition indexing structure

Return type

numpy.ndArray

clear_indexing_filtering_structures() → None

Initialize all the filtering/indexing structures.

property edges
fast_init(node_id: str) → None

Initializes all the necessary structures for parameters estimation of the node identified by the label node_id

Parameters

node_id (string) – the label of the node

get_node_indx(node_id) → int
get_ordered_by_indx_set_of_parents(node: str) → Tuple

Builds the aggregated structure that holds all the infos relative to the parent set of the node, namely (parents_labels, parents_indexes, parents_cardinalities).

Parameters

node (string) – the label of the node

Returns

a tuple containing all the parent set infos

Return type

Tuple

get_parents_by_id(node_id) → List

Returns a list of labels of the parents of the node node_id

Parameters

node_id (string) – the node label

Returns

a List of labels of the parents

Return type

List

get_positional_node_indx(node_id) → int
get_states_number(node_id) → int
has_edge(edge: tuple) → bool

Check if the graph contains a specific edge

Parameters:

edge: a tuple that rappresents the edge

Returns:

bool

init_graph()
property nodes
property nodes_indexes
property nodes_values
property p_combs
remove_edges(list_of_edges: List) → None

Remove the edges to the graph contained in the list list_of_edges.

Parameters

list_of_edges (List) – The edges to remove from the graph

remove_node(node_id: str) → None

Remove the node node_id from all the class members. Initialize all the filtering/indexing structures.

property time_filtering
property time_scalar_indexing_strucure
property transition_filtering
property transition_scalar_indexing_structure

classes.structure_graph.sample_path module

class classes.structure_graph.sample_path.SamplePath(importer: classes.utility.abstract_importer.AbstractImporter)

Bases: object

Aggregates all the informations about the trajectories, the real structure of the sampled net and variables cardinalites. Has the task of creating the objects Trajectory and Structure that will contain the mentioned data.

Parameters

importer (AbstractImporter) – the Importer object which contains the imported and processed data

_trajectories

the Trajectory object that will contain all the concatenated trajectories

_structure

the Structure Object that will contain all the structural infos about the net

_total_variables_count

the number of variables in the net

build_structure() → None

Builds the Structure object that aggregates all the infos about the net.

build_trajectories() → None

Builds the Trajectory object that will contain all the trajectories. Clears all the unused dataframes in _importer Object

clear_memory()
property has_prior_net_structure
property structure
property total_variables_count
property trajectories

classes.structure_graph.set_of_cims module

class classes.structure_graph.set_of_cims.SetOfCims(node_id: str, parents_states_number: List, node_states_number: int, p_combs: numpy.ndarray)

Bases: object

Aggregates all the CIMS of the node identified by the label _node_id.

Parameters
  • node_id – the node label

  • parents_states_number (List) – the cardinalities of the parents

  • node_states_number (int) – the caridinality of the node

  • p_combs (numpy.ndArray) – the p_comb structure bound to this node

_state_residence_time

matrix containing all the state residence time vectors for the node

_transition_matrices

matrix containing all the transition matrices for the node

_actual_cims

the cims of the node

property actual_cims
build_cims(state_res_times: numpy.ndarray, transition_matrices: numpy.ndarray) → None

Build the ConditionalIntensityMatrix objects given the state residence times and transitions matrices. Compute the cim coefficients.The class member _actual_cims will contain the computed cims.

Parameters
  • state_res_times (numpy.ndArray) – the state residence times matrix

  • transition_matrices (numpy.ndArray) – the transition matrices

build_times_and_transitions_structures() → None

Initializes at the correct dimensions the state residence times matrix and the state transition matrices.

filter_cims_with_mask(mask_arr: numpy.ndarray, comb: List) → numpy.ndarray

Filter the cims contained in the array _actual_cims given the boolean mask mask_arr and the index comb.

Parameters
  • mask_arr (numpy.array) – the boolean mask that indicates which parent to consider

  • comb (numpy.array) – the state/s of the filtered parents

Returns

Array of ConditionalIntensityMatrix objects

Return type

numpy.array

get_cims_number()
property p_combs

classes.structure_graph.sets_of_cims_container module

class classes.structure_graph.sets_of_cims_container.SetsOfCimsContainer(list_of_keys, states_number_per_node, list_of_parents_states_number, p_combs_list)

Bases: object

Aggrega un insieme di oggetti SetOfCims

get_cims_of_node(node_indx, cim_indx)
get_set_of_cims(node_indx)
init_cims_structure(keys, states_number_per_node, list_of_parents_states_number, p_combs_list)

for indx, key in enumerate(keys): self.sets_of_cims.append(

socim.SetOfCims(key, list_of_parents_states_number[indx], states_number_per_node[indx]))

classes.structure_graph.structure module

class classes.structure_graph.structure.Structure(nodes_labels_list: List, nodes_indexes_arr: numpy.ndarray, nodes_vals_arr: numpy.ndarray, edges_list: List, total_variables_number: int)

Bases: object

Contains all the infos about the network structure(nodes labels, nodes caridinalites, edges, indexes)

Parameters
  • nodes_labels_list (List) – the symbolic names of the variables

  • nodes_indexes_arr (numpy.ndArray) – the indexes of the nodes

  • nodes_vals_arr (numpy.ndArray) – the cardinalites of the nodes

  • edges_list (List) – the edges of the network

  • total_variables_number (int) – the total number of variables in the dataset

add_edge(edge: tuple)
clean_structure_edges()
contains_edge(edge: tuple) → bool
property edges
get_node_id(node_indx: int) → str

Given the node_index returns the node label.

Parameters

node_indx (int) – the node index

Returns

the node label

Return type

string

get_node_indx(node_id: str) → int

Given the node_index returns the node label.

Parameters

node_id (string) – the node label

Returns

the node index

Return type

int

get_positional_node_indx(node_id: str) → int
get_states_number(node: str) → int

Given the node label node returns the cardinality of the node.

Parameters

node (string) – the node label

Returns

the node cardinality

Return type

int

property nodes_indexes
property nodes_labels
property nodes_values
remove_edge(edge: tuple)
remove_node(node_id: str) → None

Remove the node node_id from all the class members. The class member _total_variables_number since it refers to the total number of variables in the dataset.

property total_variables_number

classes.structure_graph.trajectory module

class classes.structure_graph.trajectory.Trajectory(list_of_columns: List, original_cols_number: int)

Bases: object

Abstracts the infos about a complete set of trajectories, represented as a numpy array of doubles (the time deltas) and a numpy matrix of ints (the changes of states).

Parameters
  • list_of_columns (List) – the list containing the times array and values matrix

  • original_cols_number (int) – total number of cols in the data

_actual_trajectory

the trajectory containing also the duplicated/shifted values

_times

the array containing the time deltas

property complete_trajectory
size()
property times
property trajectory

Module contents


© Copyright 2021, Bregoli Alessandro, Martini Filippo, Moretti Luca.

Built with Sphinx using a theme provided by Porão do Juca.