Skip to content

Commit

Permalink
DOC Ensures that KNeighborsTransformer passes numpydoc validation (sc…
Browse files Browse the repository at this point in the history
…ikit-learn#20805)

Co-authored-by: Guillaume Lemaitre <[email protected]>
  • Loading branch information
jmloyola and glemaitre authored Aug 22, 2021
1 parent c63b8d8 commit 03245ee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
1 change: 0 additions & 1 deletion maint_tools/test_docstrings.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"IterativeImputer",
"KBinsDiscretizer",
"KNNImputer",
"KNeighborsTransformer",
"KernelPCA",
"LabelBinarizer",
"LabelPropagation",
Expand Down
18 changes: 14 additions & 4 deletions sklearn/neighbors/_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def radius_neighbors_graph(


class KNeighborsTransformer(KNeighborsMixin, TransformerMixin, NeighborsBase):
"""Transform X into a (weighted) graph of k nearest neighbors
"""Transform X into a (weighted) graph of k nearest neighbors.
The transformed data is a sparse graph as returned by kneighbors_graph.
Expand Down Expand Up @@ -258,7 +258,7 @@ class KNeighborsTransformer(KNeighborsMixin, TransformerMixin, NeighborsBase):
nature of the problem.
metric : str or callable, default='minkowski'
metric to use for distance computation. Any metric from scikit-learn
Metric to use for distance computation. Any metric from scikit-learn
or scipy.spatial.distance can be used.
If metric is a callable function, it is called on each
Expand Down Expand Up @@ -317,6 +317,13 @@ class KNeighborsTransformer(KNeighborsMixin, TransformerMixin, NeighborsBase):
n_samples_fit_ : int
Number of samples in the fitted data.
See Also
--------
kneighbors_graph : Compute the weighted graph of k-neighbors for
points in X.
RadiusNeighborsTransformer : Transform X into a weighted graph of
neighbors nearer than a radius.
Examples
--------
>>> from sklearn.manifold import Isomap
Expand Down Expand Up @@ -359,6 +366,8 @@ def fit(self, X, y=None):
X : {array-like, sparse matrix} of shape (n_samples, n_features) or \
(n_samples, n_samples) if metric='precomputed'
Training data.
y : Ignored
Not used, present for API consistency by convention.
Returns
-------
Expand All @@ -368,7 +377,7 @@ def fit(self, X, y=None):
return self._fit(X)

def transform(self, X):
"""Computes the (weighted) graph of Neighbors for points in X
"""Compute the (weighted) graph of Neighbors for points in X.
Parameters
----------
Expand Down Expand Up @@ -400,7 +409,8 @@ def fit_transform(self, X, y=None):
X : array-like of shape (n_samples, n_features)
Training set.
y : ignored
y : Ignored
Not used, present for API consistency by convention.
Returns
-------
Expand Down

0 comments on commit 03245ee

Please sign in to comment.