sklearn.metrics.pairwise
.paired_distances¶
-
sklearn.metrics.pairwise.
paired_distances
(X, Y, metric='euclidean', **kwds)[source]¶ Computes the paired distances between X and Y.
Computes the distances between (X[0], Y[0]), (X[1], Y[1]), etc…
Read more in the User Guide.
- Parameters
- Xndarray (n_samples, n_features)
Array 1 for distance computation.
- Yndarray (n_samples, n_features)
Array 2 for distance computation.
- metricstring or callable
The metric to use when calculating distance between instances in a feature array. If metric is a string, it must be one of the options specified in PAIRED_DISTANCES, including “euclidean”, “manhattan”, or “cosine”. Alternatively, if metric is a callable function, it is called on each pair of instances (rows) and the resulting value recorded. The callable should take two arrays from X as input and return a value indicating the distance between them.
- Returns
- distancesndarray (n_samples, )
See also
pairwise_distances
Computes the distance between every pair of samples
Examples
>>> from sklearn.metrics.pairwise import paired_distances >>> X = [[0, 1], [1, 1]] >>> Y = [[0, 1], [2, 1]] >>> paired_distances(X, Y) array([0., 1.])