aspcol.distance.angular_distance

aspcol.distance.angular_distance(vec1, vec2, sign_invariant=False)
A distance metric based on the cosine similary, that retains the

scale invariant property, but is also a proper distance metric

Parameters:
  • vec1 (np.ndarray of shape (N,)) – First vector

  • vec2 (np.ndarray of shape (N,)) – Second vector

  • sign_invariant (bool, optional) – if True, the angle is first adjusted to a range between 1 and 0 meaning that parallell vectors and opposite vectors are both considered to be the same If False, the same shape but opposite signs gives maximum distance

Returns:

ang_dist – The angular distance between the two vectors, in the range [0, 1]

Return type:

float