Main#

chebyshev(vector_1: list, vector_2: list) float[source]#

Computes the Chebyshev distance.

Parameters:
  • vector_1 (list) – First vector.

  • vector_2 (list) – Second vector.

Returns:

Chebyshev distance.

Return type:

float

discrete(vector_1, vector_2) int[source]#

Computes the discrete distance.

Parameters:
  • vector_1 – First vector.

  • vector_2 – Second vector.

Returns:

Discrete distance.

Return type:

int

emd(vector_1: list, vector_2: list) float[source]#

Computes the EMD distance.

Parameters:
  • vector_1 (list) – First vector.

  • vector_2 (list) – Second vector.

Returns:

EMD distance.

Return type:

float

emdinf(vector_1: list, vector_2: list) float[source]#

Computes the EMD-infinity distance.

Parameters:
  • vector_1 (list) – First vector.

  • vector_2 (list) – Second vector.

Returns:

EMD-infinity distance.

Return type:

float

extract_distance_id(distance_id: str) -> (<built-in function callable>, <class 'str'>)[source]#

Extracts inner distance and main distance from distance_id.

Parameters:

distance_id (str) – Name of the distance.

Returns:

  • callable – Inner distance.

  • str – Main distance.

hamming(set_1: set, set_2: set) int[source]#

Computes the Hamming distance between two sets.

Parameters:
  • set_1 (set) – First vector.

  • set_2 (set) – Second vector.

Returns:

Hamming distance.

Return type:

int

hellinger(vector_1: list, vector_2: list) float[source]#

Computes the Hellinger distance.

Parameters:
  • vector_1 (list) – First vector.

  • vector_2 (list) – Second vector.

Returns:

Hellinger distance.

Return type:

float

l1(vector_1: ndarray, vector_2: ndarray) float[source]#

Computes the L1 distance.

Parameters:
  • vector_1 (np.ndarray) – First vector.

  • vector_2 (np.ndarray) – Second vector.

Returns:

L1 distance.

Return type:

float

l2(vector_1: ndarray, vector_2: ndarray) float[source]#

Computes the L2 distance.

Parameters:
  • vector_1 (np.ndarray) – First vector.

  • vector_2 (np.ndarray) – Second vector.

Returns:

L2 distance.

Return type:

float

map_str_to_func(name: str) callable[source]#

Maps a string to a function.

Parameters:

name (str) – Name of the distance.

Return type:

callable

run_multiple_processes(experiment, instances_ids: list, distances: dict, times: dict, matchings: dict, process_id: int) None[source]#

Calculates distances between each pair of instances (using multiple processes).

Parameters:
  • experiment (Experiment) – Experiment object.

  • instances_ids (list) – List of the Ids.

  • distances (dict) – Dictionary with distances between each pair of instances

  • times (dict) – Dictionary with time of calculation of each distance.

  • matchings (dict) – Dictionary with matchings between each pair of instances.

  • process_id (int) – ID of the process.

Return type:

None

run_single_process(experiment, instances_ids: list, distances: dict, times: dict, matchings: dict) None[source]#

Calculates distances between each pair of instances (using single process).

Parameters:
  • experiment (Experiment) – Experiment object.

  • instances_ids (list) – List of the Ids.

  • distances (dict) – Dictionary with distances between each pair of instances

  • times (dict) – Dictionary with time of calculation of each distance.

  • matchings (dict) – Dictionary with matchings between each pair of instances.

Return type:

None

single_l1(value_1, value_2) float[source]#

Computes the L1 distance between two values.

Parameters:
  • value_1 – First value.

  • value_2 – Second values.

Returns:

L1 distance.

Return type:

float

spearman_distance_between_potes(pote_1: list, pote_2: list) int[source]#

Computes the Spearman distance between two potes (i.e. positional votes).

Parameters:
  • pote_1 (list) – First vector.

  • pote_2 (list) – Second vector.

Returns:

Spearman distance.

Return type:

int

swap_distance(vote_1: list, vote_2: list, matching=None) int[source]#

Return: Swap distance between two votes

swap_distance_between_potes(pote_1: list, pote_2: list) int[source]#

Computes the swap distance between two potes (i.e. positional votes).

Parameters:
  • pote_1 (list) – First vector.

  • pote_2 (list) – Second vector.

Returns:

Swap distance.

Return type:

int

vote_to_pote(vote: list) list[source]#

Converts vote to pote (i.e. positional vote)

Parameters:

vote (list) – Ordinal vote.

Returns:

Potes (i.e. positional votes).

Return type:

list