cupyx.scipy.spatial.distance.pdist#
- cupyx.scipy.spatial.distance.pdist(X, metric='euclidean', *, out=None, **kwargs)[source]#
Compute distance between observations in n-dimensional space.
- Parameters:
X (array_like) – An \(m\) by \(n\) array of \(m\) original observations in an \(n\)-dimensional space. Inputs are converted to float type.
metric (str, optional) – The distance metric to use. The distance function can be ‘canberra’, ‘chebyshev’, ‘cityblock’, ‘correlation’, ‘cosine’, ‘euclidean’, ‘hamming’, ‘hellinger’, ‘jensenshannon’, ‘kl_divergence’, ‘matching’, ‘minkowski’, ‘russellrao’, ‘sqeuclidean’.
out (cupy.ndarray, optional) – The output array. If not None, the distance matrix Y is stored in this array.
**kwargs (dict, optional) – Extra arguments to metric: refer to each metric documentation for a list of all possible arguments. Some possible arguments: p (float): The p-norm to apply for Minkowski, weighted and unweighted. Default: 2.0
- Returns:
Returns a condensed distance matrix Y. For each \(i\) and \(j\) and (where \(i < j < m\)), where m is the number of original observations. The metric
dist(u=X[i], v=X[j])
is computed and stored in entrym * i + j - ((i + 2) * (i + 1)) // 2
.- Return type:
Y (cupy.ndarray)