bulk_harris_lahey_binary_similarity#

skfp.distances.bulk_harris_lahey_binary_similarity(X: ndarray, Y: ndarray | None = None, normalized: bool = False) ndarray#

Bulk Harris-Lahey similarity for binary matrices.

Computes the pairwise Harris-Lahey similarity between binary matrices. If one array is passed, similarities are computed between its rows. For two arrays, similarities are between their respective rows, with i-th row and j-th column in output corresponding to i-th row from first array and j-th row from second array.

See also harris_lahey_binary_similarity().

Parameters:
  • X (ndarray) – First binary input array, of shape \(m \times m\)

  • Y (ndarray, default=None) – Second binary input array, of shape \(n \times n\). If not passed, similarities are computed between rows of X.

  • normalized (bool, default=False) – Whether to divide the resulting similarity by length of vectors, (their number of elements), to normalize values to range [0, 1].

Returns:

similarities – Array with pairwise Harris-Lahey similarity values. Shape is \(m \times n\) if two arrays are passed, or \(m \times m\) otherwise.

Return type:

ndarray

See also

harris_lahey_binary_similarity()

Harris-Lahey similarity function for two vectors.

Examples

>>> from skfp.distances import bulk_harris_lahey_binary_similarity
>>> import numpy as np
>>> X = np.array([[1, 0, 1], [0, 0, 1]])
>>> Y = np.array([[1, 0, 1], [0, 1, 1]])
>>> sim = bulk_harris_lahey_binary_similarity(X, Y)
>>> sim
array([[3.        , 0.33333333],
       [1.5       , 1.5       ]])