Distance computations (cupyx.scipy.spatial.distance)#

Note

The distance module uses pylibraft as a backend. You need to install pylibraft package <https://anaconda.org/rapidsai/pylibraft> from rapidsai Conda channel to use features listed on this page.

Note

Currently, the distance module is not supported on AMD ROCm platforms.

Distance matrix computations#

Distance matrix computation from a collection of raw observation vectors stored in a rectangular array.

pdist(X[, metric, out])

Compute distance between observations in n-dimensional space.

cdist(XA, XB[, metric, out])

Compute distance between each pair of the two collections of inputs.

distance_matrix(x, y[, p])

Compute the distance matrix.

Distance functions#

Distance functions between two numeric vectors u and v. Computing distances over a large collection of vectors is inefficient for these functions. Use cdist for this purpose.

minkowski(u, v, p)

Compute the Minkowski distance between two 1-D arrays.

canberra(u, v)

Compute the Canberra distance between two 1-D arrays.

chebyshev(u, v)

Compute the Chebyshev distance between two 1-D arrays.

cityblock(u, v)

Compute the City Block (Manhattan) distance between two 1-D arrays.

correlation(u, v)

Compute the correlation distance between two 1-D arrays.

cosine(u, v)

Compute the Cosine distance between two 1-D arrays.

hamming(u, v)

Compute the Hamming distance between two 1-D arrays.

euclidean(u, v)

Compute the Euclidean distance between two 1-D arrays.

jensenshannon(u, v)

Compute the Jensen-Shannon distance between two 1-D arrays.

russellrao(u, v)

Compute the Russell-Rao distance between two 1-D arrays.

sqeuclidean(u, v)

Compute the squared Euclidean distance between two 1-D arrays.

hellinger(u, v)

Compute the Hellinger distance between two 1-D arrays.

kl_divergence(u, v)

Compute the Kullback-Leibler divergence between two 1-D arrays.