Skip to content

Commit 03245ee

Browse files
jmloyolaglemaitre
andauthored
DOC Ensures that KNeighborsTransformer passes numpydoc validation (scikit-learn#20805)
Co-authored-by: Guillaume Lemaitre <[email protected]>
1 parent c63b8d8 commit 03245ee

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
"IterativeImputer",
3939
"KBinsDiscretizer",
4040
"KNNImputer",
41-
"KNeighborsTransformer",
4241
"KernelPCA",
4342
"LabelBinarizer",
4443
"LabelPropagation",

sklearn/neighbors/_graph.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def radius_neighbors_graph(
218218

219219

220220
class KNeighborsTransformer(KNeighborsMixin, TransformerMixin, NeighborsBase):
221-
"""Transform X into a (weighted) graph of k nearest neighbors
221+
"""Transform X into a (weighted) graph of k nearest neighbors.
222222
223223
The transformed data is a sparse graph as returned by kneighbors_graph.
224224
@@ -258,7 +258,7 @@ class KNeighborsTransformer(KNeighborsMixin, TransformerMixin, NeighborsBase):
258258
nature of the problem.
259259
260260
metric : str or callable, default='minkowski'
261-
metric to use for distance computation. Any metric from scikit-learn
261+
Metric to use for distance computation. Any metric from scikit-learn
262262
or scipy.spatial.distance can be used.
263263
264264
If metric is a callable function, it is called on each
@@ -317,6 +317,13 @@ class KNeighborsTransformer(KNeighborsMixin, TransformerMixin, NeighborsBase):
317317
n_samples_fit_ : int
318318
Number of samples in the fitted data.
319319
320+
See Also
321+
--------
322+
kneighbors_graph : Compute the weighted graph of k-neighbors for
323+
points in X.
324+
RadiusNeighborsTransformer : Transform X into a weighted graph of
325+
neighbors nearer than a radius.
326+
320327
Examples
321328
--------
322329
>>> from sklearn.manifold import Isomap
@@ -359,6 +366,8 @@ def fit(self, X, y=None):
359366
X : {array-like, sparse matrix} of shape (n_samples, n_features) or \
360367
(n_samples, n_samples) if metric='precomputed'
361368
Training data.
369+
y : Ignored
370+
Not used, present for API consistency by convention.
362371
363372
Returns
364373
-------
@@ -368,7 +377,7 @@ def fit(self, X, y=None):
368377
return self._fit(X)
369378

370379
def transform(self, X):
371-
"""Computes the (weighted) graph of Neighbors for points in X
380+
"""Compute the (weighted) graph of Neighbors for points in X.
372381
373382
Parameters
374383
----------
@@ -400,7 +409,8 @@ def fit_transform(self, X, y=None):
400409
X : array-like of shape (n_samples, n_features)
401410
Training set.
402411
403-
y : ignored
412+
y : Ignored
413+
Not used, present for API consistency by convention.
404414
405415
Returns
406416
-------

0 commit comments

Comments
 (0)