fatf.utils.distances.get_distance_matrix

fatf.utils.distances.get_distance_matrix(data_array: numpy.ndarray, distance_function: Callable[[numpy.ndarray, numpy.ndarray], float]) → numpy.ndarray[source]

Computes a distance matrix (2-D) between all rows of the data_array.

Parameters
data_arraynumpy.ndarray

A 2-dimensional numpy array for which row-to-row distances will be computed.

distance_functionCallable[[numpy.ndarray, numpy.ndarray], number]

A Python function that takes as an input two 1-dimensional numpy arrays of equal length and outputs a number representing a distance between them. The distance function is assumed to return the same distance regardless of the order in which parameters are given.

Returns
distancesnumpy.ndarray

A square numerical numpy array with distances between all pairs of data points (rows) in the data_array.

Raises
AttributeError

The distance function does not require exactly two parameters.

IncorrectShapeError

The data array is not a 2-dimensional numpy array.

TypeError

The data array is not of a base type (numbers and/or strings). The distance function is not a Python callable (function).