docarray.math.distance.numpy module#
- docarray.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=2y_mat (
ndarray
) – np.ndarray with ndim=2eps (
float
) – a small jitter to avoid divde by zero
- Return type:
ndarray
- Returns:
np.ndarray with ndim=2
- docarray.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
- docarray.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
- docarray.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
- docarray.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
- docarray.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