Skip to content

Commit 7446009

Browse files
authored
DOC Make references to scipy modules/functions links in pairwise.py (scikit-learn#31694)
1 parent ef1e77f commit 7446009

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

sklearn/metrics/pairwise.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -305,7 +305,7 @@ def euclidean_distances(
305305
However, this is not the most precise way of doing this computation,
306306
because this equation potentially suffers from "catastrophic cancellation".
307307
Also, the distance matrix returned by this function may not be exactly
308-
symmetric as required by, e.g., ``scipy.spatial.distance`` functions.
308+
symmetric as required by, e.g., :mod:`scipy.spatial.distance` functions.
309309
310310
Read more in the :ref:`User Guide <metrics>`.
311311
@@ -757,7 +757,7 @@ def pairwise_distances_argmin_min(
757757
758758
metric : str or callable, default='euclidean'
759759
Metric to use for distance computation. Any metric from scikit-learn
760-
or scipy.spatial.distance can be used.
760+
or :mod:`scipy.spatial.distance` can be used.
761761
762762
If metric is a callable function, it is called on each
763763
pair of instances (rows) and the resulting value recorded. The callable
@@ -772,13 +772,13 @@ def pairwise_distances_argmin_min(
772772
- from scikit-learn: ['cityblock', 'cosine', 'euclidean', 'l1', 'l2',
773773
'manhattan', 'nan_euclidean']
774774
775-
- from scipy.spatial.distance: ['braycurtis', 'canberra', 'chebyshev',
775+
- from :mod:`scipy.spatial.distance`: ['braycurtis', 'canberra', 'chebyshev',
776776
'correlation', 'dice', 'hamming', 'jaccard', 'kulsinski',
777777
'mahalanobis', 'minkowski', 'rogerstanimoto', 'russellrao',
778778
'seuclidean', 'sokalmichener', 'sokalsneath', 'sqeuclidean',
779779
'yule']
780780
781-
See the documentation for scipy.spatial.distance for details on these
781+
See the documentation for :mod:`scipy.spatial.distance` for details on these
782782
metrics.
783783
784784
.. note::
@@ -905,7 +905,7 @@ def pairwise_distances_argmin(X, Y, *, axis=1, metric="euclidean", metric_kwargs
905905
906906
metric : str or callable, default="euclidean"
907907
Metric to use for distance computation. Any metric from scikit-learn
908-
or scipy.spatial.distance can be used.
908+
or :mod:`scipy.spatial.distance` can be used.
909909
910910
If metric is a callable function, it is called on each
911911
pair of instances (rows) and the resulting value recorded. The callable
@@ -920,13 +920,13 @@ def pairwise_distances_argmin(X, Y, *, axis=1, metric="euclidean", metric_kwargs
920920
- from scikit-learn: ['cityblock', 'cosine', 'euclidean', 'l1', 'l2',
921921
'manhattan', 'nan_euclidean']
922922
923-
- from scipy.spatial.distance: ['braycurtis', 'canberra', 'chebyshev',
923+
- from :mod:`scipy.spatial.distance`: ['braycurtis', 'canberra', 'chebyshev',
924924
'correlation', 'dice', 'hamming', 'jaccard', 'kulsinski',
925925
'mahalanobis', 'minkowski', 'rogerstanimoto', 'russellrao',
926926
'seuclidean', 'sokalmichener', 'sokalsneath', 'sqeuclidean',
927927
'yule']
928928
929-
See the documentation for scipy.spatial.distance for details on these
929+
See the documentation for :mod:`scipy.spatial.distance` for details on these
930930
metrics.
931931
932932
.. note::
@@ -2146,7 +2146,7 @@ def pairwise_distances_chunked(
21462146
metric : str or callable, default='euclidean'
21472147
The metric to use when calculating distance between instances in a
21482148
feature array. If metric is a string, it must be one of the options
2149-
allowed by scipy.spatial.distance.pdist for its metric parameter,
2149+
allowed by :func:`scipy.spatial.distance.pdist` for its metric parameter,
21502150
or a metric listed in pairwise.PAIRWISE_DISTANCE_FUNCTIONS.
21512151
If metric is "precomputed", X is assumed to be a distance matrix.
21522152
Alternatively, if metric is a callable function, it is called on
@@ -2170,7 +2170,7 @@ def pairwise_distances_chunked(
21702170
21712171
**kwds : optional keyword parameters
21722172
Any further parameters are passed directly to the distance function.
2173-
If using a scipy.spatial.distance metric, the parameters are still
2173+
If using a :mod:`scipy.spatial.distance` metric, the parameters are still
21742174
metric dependent. See the scipy docs for usage examples.
21752175
21762176
Yields
@@ -2326,12 +2326,11 @@ def pairwise_distances(
23262326
'manhattan', 'nan_euclidean']. All metrics support sparse matrix
23272327
inputs except 'nan_euclidean'.
23282328
2329-
- From scipy.spatial.distance: ['braycurtis', 'canberra', 'chebyshev',
2329+
- From :mod:`scipy.spatial.distance`: ['braycurtis', 'canberra', 'chebyshev',
23302330
'correlation', 'dice', 'hamming', 'jaccard', 'kulsinski', 'mahalanobis',
23312331
'minkowski', 'rogerstanimoto', 'russellrao', 'seuclidean',
2332-
'sokalmichener', 'sokalsneath', 'sqeuclidean', 'yule']
2333-
See the documentation for scipy.spatial.distance for details on these
2334-
metrics. These metrics do not support sparse matrix inputs.
2332+
'sokalmichener', 'sokalsneath', 'sqeuclidean', 'yule'].
2333+
These metrics do not support sparse matrix inputs.
23352334
23362335
.. note::
23372336
`'kulsinski'` is deprecated from SciPy 1.9 and will be removed in SciPy 1.11.
@@ -2340,7 +2339,7 @@ def pairwise_distances(
23402339
`'matching'` has been removed in SciPy 1.9 (use `'hamming'` instead).
23412340
23422341
Note that in the case of 'cityblock', 'cosine' and 'euclidean' (which are
2343-
valid scipy.spatial.distance metrics), the scikit-learn implementation
2342+
valid :mod:`scipy.spatial.distance` metrics), the scikit-learn implementation
23442343
will be used, which is faster and has support for sparse matrices (except
23452344
for 'cityblock'). For a verbose description of the metrics from
23462345
scikit-learn, see :func:`sklearn.metrics.pairwise.distance_metrics`
@@ -2363,7 +2362,7 @@ def pairwise_distances(
23632362
metric : str or callable, default='euclidean'
23642363
The metric to use when calculating distance between instances in a
23652364
feature array. If metric is a string, it must be one of the options
2366-
allowed by scipy.spatial.distance.pdist for its metric parameter, or
2365+
allowed by :func:`scipy.spatial.distance.pdist` for its metric parameter, or
23672366
a metric listed in ``pairwise.PAIRWISE_DISTANCE_FUNCTIONS``.
23682367
If metric is "precomputed", X is assumed to be a distance matrix.
23692368
Alternatively, if metric is a callable function, it is called on each

0 commit comments

Comments
 (0)