hal.data package

Submodules

hal.data.dicts module

Typical operations on dicts made easy

hal.data.dicts.get_inner_data(dictionary)[source]

Gets 2nd-level data into 1st-level dictionary

Parameters:dictionary – dict
Returns:with 2nd-level data
hal.data.dicts.get_inner_keys(dictionary)[source]

Gets 2nd-level dictionary keys

Parameters:dictionary – dict
Returns:inner keys
hal.data.dicts.how_similar_dicts(dict1, dict2)[source]

Calculates similarity

Parameters:
  • dict1 – Dictionary
  • dict2 – Dictionary
Returns:

measure of how much similar values of dictionaries are

hal.data.linked_list module

Linked list implementation

class hal.data.linked_list.LinkedList(lst)[source]

Bases: object

Models a linked list

execute(func, *args, **kwargs)[source]

Executes function on each item

Parameters:
  • func – Function to execute on each item
  • args – args of function
  • kwargs – extra args of function
Returns:

list: Results of calling the function on each item

static from_list(lst)[source]

Parses list

Parameters:lst – list of elements
Returns:LinkedList: Nodes from list
get(position)[source]

Gets value at index

Parameters:position – index
Returns:value at position
get_head()[source]

Gets head

Returns:Head of linked list
get_tail()[source]

Gets tail

Returns:Tail of linked list
insert(val, position=0)[source]

Insert in position

Parameters:
  • val – Object to insert
  • position – Index of insertion
Returns:

bool: True iff insertion completed successfully

insert_first(val)[source]

Insert in head

Parameters:val – Object to insert
Returns:True iff insertion completed successfully
insert_last(val)[source]

Appends to list

Parameters:val – Object to insert
Returns:bool: Appends element to last
length()[source]

Gets length

Returns:How many items in linked list of linked list
remove(position)[source]

Removes at index

Parameters:position – Index of removal
Returns:bool: True iff removal completed successfully
remove_first()[source]

Removes first

Returns:True iff head has been removed
remove_last()[source]

Removes last

Returns:True iff last element has been removed
to_lst()[source]

Cycle all items and puts them in a list

Returns:list representation
class hal.data.linked_list.Node(val, next_node=None)[source]

Bases: object

Node of a linked list

hal.data.lists module

Tools to deal with lists

hal.data.lists.find_commons(lists)[source]

Finds common values

Parameters:lists – List of lists
Returns:List of values that are in common between inner lists
hal.data.lists.is_in_all(value, lists)[source]

Checks if item is in all lists

Parameters:
  • value – Value to check
  • lists – List of lists
Returns:

True iff value is in all inner lists

hal.data.lists.normalize_array(lst)[source]

Normalizes list

Parameters:lst – Array of floats
Returns:Normalized (in [0, 1]) input array
hal.data.lists.pearson(lst1, lst2)[source]

Calculates pearson coefficient of arrays

Parameters:
  • lst1 – first list
  • lst2 – second list
Returns:

Pearson coefficient of arrays

hal.data.matrix module

Functions to deal with matrices

class hal.data.matrix.Matrix(matrix)[source]

Bases: object

Table of data

accuracy()[source]

Calculates accuracy

Returns:Accuracy
decode(encoder)[source]

Decodes matrix

Parameters:encoder – Encoder used to encode matrix
Returns:list: Decodes matrix
encode()[source]

Encodes matrix

Returns:Encoder used
f1_score()[source]

Calculates F1 score

Returns:F1 score
static from_columns(columns)[source]

Parses raw columns

Parameters:columns – matrix divided into columns
Returns:Matrix: Merge the columns to form a matrix
get_as_list()[source]

List of all values in matrix

Returns:list representation
get_column(index)[source]

Gets column at given index

Parameters:index – index of column
Returns:Column
precision()[source]

Calculates precision

Returns:Precision of matrix
recall()[source]

Calculates recall

Returns:Recall
true_neg_rate()[source]

Calculates true negative rate

Returns:true negative rate