paired_distances(X, Y, *, metric='euclidean', **kwds)¶
Computes the paired distances between X and Y.
Computes the distances between (X, Y), (X, Y), etc…
Read more in the User Guide.
- 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.
- distancesndarray (n_samples, )
Computes the distance between every pair of samples
>>> from sklearn.metrics.pairwise import paired_distances >>> X = [[0, 1], [1, 1]] >>> Y = [[0, 1], [2, 1]] >>> paired_distances(X, Y) array([0., 1.])