10000 DOC Ensures that metrics.pairwise.euclidean_distances passes numpydoc… · scikit-learn/scikit-learn@cbf04c9 · GitHub
[go: up one dir, main page]

Skip to content

Commit cbf04c9

Browse files
embanderaglemaitre
andauthored
DOC Ensures that metrics.pairwise.euclidean_distances passes numpydoc validation (#21429)
Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
1 parent 6f720c5 commit cbf04c9

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@
153153
"sklearn.metrics.pairwise.cosine_distances",
154154
"sklearn.metrics.pairwise.cosine_similarity",
155155
"sklearn.metrics.pairwise.distance_metrics",
156-
"sklearn.metrics.pairwise.euclidean_distances",
157156
"sklearn.metrics.pairwise.haversine_distances",
158157
"sklearn.metrics.pairwise.kernel_metrics",
159158
"sklearn.metrics.pairwise.laplacian_kernel",

sklearn/metrics/pairwise.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,7 @@ def euclidean_distances(
227227
X, Y=None, *, Y_norm_squared=None, squared=False, X_norm_squared=None
228228
):
229229
"""
230-
Considering the rows of X (and Y=X) as vectors, compute the
231-
distance matrix between each pair of vectors.
230+
Compute the distance matrix between each pair from a vector array X and Y.
232231
233232
For efficiency reasons, the euclidean distance between a pair of row
234233
vector x and y is computed as::
@@ -250,10 +249,12 @@ def euclidean_distances(
250249
Parameters
251250
----------
252251
X : {array-like, sparse matrix} of shape (n_samples_X, n_features)
252+
An array where each row is a sample and each column is a feature.
253253
254254
Y : {array-like, sparse matrix} of shape (n_samples_Y, n_features), \
255255
default=None
256-
If `None`, uses `Y=X`.
256+
An array where each row is a sample and each column is a feature.
257+
If `None`, method uses `Y=X`.
257258
258259
Y_norm_squared : array-like of shape (n_samples_Y,) or (n_samples_Y, 1) \
259260
or (1, n_samples_Y), default=None
@@ -270,19 +271,21 @@ def euclidean_distances(
270271
``(X**2).sum(axis=1)``)
271272
May be ignored in some cases, see the note below.
272273
273-
Notes
274-
-----
275-
To achieve better accuracy, `X_norm_squared` and `Y_norm_squared` may be
276-
unused if they are passed as ``float32``.
277-
278274
Returns
279275
-------
280276
distances : ndarray of shape (n_samples_X, n_samples_Y)
277+
Returns the distances between the row vectors of `X`
278+
and the row vectors of `Y`.
281279
282280
See Also
283281
--------
284282
paired_distances : Distances betweens pairs of elements of X and Y.
285283
284+
Notes
285+
-----
286+
To achieve a better accuracy, `X_norm_squared` and `Y_norm_squared` may be
287+
unused if they are passed as `np.float32`.
288+
286289
Examples
287290
--------
288291
>>> from sklearn.metrics.pairwise import euclidean_distances

0 commit comments

Comments
 (0)
0