ramen module

This section provides documentation for public APIs for RAMEN

class ramen.Ramen.Ramen

This is the ramen class

__init__(self, csv_data=None, ref_save_name='var_val_ref.pickle', end_string='', min_values=500)

Constructor of the Ramen Object, which will be used to run random walk and genetic algorithm.

Parameters:
  • csv_data (str) – path to the data in csv form. Mandatory

  • ref_save_name (str) – when the csv is discretized, this is the path to which the mapping of the discrete values to the actual values will be saved. Not mandatory.

  • end_string (str) – the destination variable of absorbing random walk. Mandatory.

  • min_values (int) – number of minimum values in a column, if it is less, then the variable gets pruned.

random_walk(self, num_exp=10, num_walks=50000, num_steps=7, p_value=0.05, correction='no_correction')

Method to begin the absorbing random walk once the Ramen object is initialized. The significant edges will be stored in ramen_object.signif_edges.

Parameters:
  • num_exp (int) – the number of random walk experiments. (default value is 10).

  • num_walks (int) – the number of random walks per experiment. (default value is 50000)

  • num_steps (int) – the number of steps per random walk. (default value is 7)

  • p_value (float) – the cutoff value to determine significance of edge visits. An edge is significant if it is below p_value. (default value is 0.05)

  • correction (str) – choose correction method on the significant edges p-values. (supported correction: [“fdr”, “no_correction”])

Return type:

None

genetic_algorithm(self, num_candidates=10, end_thresh=0.01, mutate_num=100, best_cand_num=10, bad_reprod_accept=10, reg_factor=0.01, hard_stop=100)

Method to begin the genetic algorithm once random walk is complete. The result neetwork will be stored in ramen_object.network.

Parameters:
  • num_candidates (int) – number of initial candidates. (default value is 10)

  • end_thresh (float) – if the score increase between generations are continuously below end_thresh, then it converges. (default value is 0.01)

  • mutate_num (int) – the number of mutations per intermediate candidate after cross breeding. (default value is 100)

  • best_cand_num (int) – the number of top candidates kept after a generation. (default value is 10)

  • bad_reprod_accept (int) – the number of generations with < end_thresh increase before convergeance. (default value is 10)

  • reg_factor (float) – score penalty per edge (default value is 0.01)

  • hard_stop (int) – maximum number of generations (default value is 100)

Return type:

None

pickle_signif_edges(self, filename='signif_edges.pickle')

Method to save the significant edges to a pickle object.

Parameters:

filename (str) – name of the save file (Default value is “signif_edges.pickle”)

Return type:

None

load_signif_edges_pickle(self, filename)

Method to load the significant edges from a pickle object.

Parameters:

filename (str) – name of the save file.

Return type:

None

pickle_final_network(self, filename='final_net.pickle')

Method to save the final network as a NetworkX DiGraph.

Parameters:

filename (str) – name of the save file. (Default value is “signif_edges.pickle”)

Return type:

None

set_end_string(self, end_string)

Method to modify the end_string of absorbing random walk.

Parameters:

end_string (str) – name of end variable.

Return type:

None

get_signif_edges(self)

Return a copy of the significant edges, or None if there are None.

Returns:

list of tuples of len 2 representing edges tup<str, str>>

Return type:

list

set_signif_edges(self, signif_edges)

Set the significant edges.

Parameters:

signif_edges (list<tup<str, str>>) – significant edges to set.

Return type:

None

get_var_ref(self)

Get the discrete to variable value reference.

Returns:

dictionary of variable value mappings.

Return type:

dict

get_mutual_info_array(self)

Get the mutual information matrix.

Returns:

2D-array containing mutual information values.

Return type:

numpy.array