jina.math.distance.numpy module

jina.math.distance.numpy.cosine(x_mat, y_mat, eps=1e-07)[source]

Cosine distance between each row in x_mat and each row in y_mat.

Parameters
  • x_mat (ndarray) – np.ndarray with ndim=2

  • y_mat (ndarray) – np.ndarray with ndim=2

  • eps (float) – a small jitter to avoid divde by zero

Return type

ndarray

Returns

np.ndarray with ndim=2

jina.math.distance.numpy.sqeuclidean(x_mat, y_mat)[source]

Squared Euclidean distance between each row in x_mat and each row in y_mat. :type x_mat: ndarray :param x_mat: np.ndarray with ndim=2 :type y_mat: ndarray :param y_mat: np.ndarray with ndim=2 :rtype: ndarray :return: np.ndarray with ndim=2

jina.math.distance.numpy.sparse_cosine(x_mat, y_mat)[source]

Cosine distance between each row in x_mat and each row in y_mat. :type x_mat: ArrayType :param x_mat: scipy.sparse like array with ndim=2 :type y_mat: ArrayType :param y_mat: scipy.sparse like array with ndim=2 :rtype: np.ndarray :return: np.ndarray with ndim=2

jina.math.distance.numpy.sparse_sqeuclidean(x_mat, y_mat)[source]

Cosine distance between each row in x_mat and each row in y_mat.

Parameters
  • x_mat (ArrayType) – scipy.sparse like array with ndim=2

  • y_mat (ArrayType) – scipy.sparse like array with ndim=2

Return type

np.ndarray

Returns

np.ndarray with ndim=2

jina.math.distance.numpy.sparse_euclidean(x_mat, y_mat)[source]

Sparse euclidean distance between each row in x_mat and each row in y_mat.

Parameters
  • x_mat (ArrayType) – scipy.sparse like array with ndim=2

  • y_mat (ArrayType) – scipy.sparse like array with ndim=2

Return type

np.ndarray

Returns

np.ndarray with ndim=2

jina.math.distance.numpy.euclidean(x_mat, y_mat)[source]

Euclidean distance between each row in x_mat and each row in y_mat.

Parameters
  • x_mat (ArrayType) – scipy.sparse like array with ndim=2

  • y_mat (ArrayType) – scipy.sparse like array with ndim=2

Return type

np.ndarray

Returns

np.ndarray with ndim=2