1
- """Base and mixin classes for nearest neighbors"""
1
+ """Base and mixin classes for nearest neighbors. """
2
2
# Authors: Jake Vanderplas <[email protected] >
3
3
# Fabian Pedregosa <[email protected] >
4
4
# Alexandre Gramfort <[email protected] >
@@ -88,7 +88,7 @@ def _check_weights(weights):
88
88
89
89
90
90
def _get_weights (dist , weights ):
91
- """Get the weights from an array of distances and a parameter ``weights``
91
+ """Get the weights from an array of distances and a parameter ``weights``.
92
92
93
93
Parameters
94
94
----------
@@ -135,7 +135,7 @@ def _get_weights(dist, weights):
135
135
136
136
137
137
def _is_sorted_by_data (graph ):
138
- """Returns whether the graph's non-zero entries are sorted by data
138
+ """Return whether the graph's non-zero entries are sorted by data.
139
139
140
140
The non-zero entries are stored in graph.data and graph.indices.
141
141
For each row (or sample), the non-zero entries can be either:
@@ -162,7 +162,7 @@ def _is_sorted_by_data(graph):
162
162
163
163
164
164
def _check_precomputed (X ):
165
- """Check precomputed distance matrix
165
+ """Check precomputed distance matrix.
166
166
167
167
If the precomputed distance matrix is sparse, it checks that the non-zero
168
168
entries are sorted by distances. If not, the matrix is copied and sorted.
@@ -223,7 +223,7 @@ def _check_precomputed(X):
223
223
224
224
225
225
def _kneighbors_from_graph (graph , n_neighbors , return_distance ):
226
- """Decompose a nearest neighbors sparse graph into distances and indices
226
+ """Decompose a nearest neighbors sparse graph into distances and indices.
227
227
228
228
Parameters
229
229
----------
@@ -275,7 +275,7 @@ def extract(a):
275
275
276
276
277
277
def _radius_neighbors_from_graph (graph , radius , return_distance ):
278
- """Decompose a nearest neighbors sparse graph into distances and indices
278
+ """Decompose a nearest neighbors sparse graph into distances and indices.
279
279
280
280
Parameters
281
281
----------
@@ -589,7 +589,7 @@ def _pairwise(self):
589
589
590
590
591
591
def _tree_query_parallel_helper (tree , * args , ** kwargs ):
592
- """Helper for the Parallel calls in KNeighborsMixin.kneighbors
592
+ """Helper for the Parallel calls in KNeighborsMixin.kneighbors.
593
593
594
594
The Cython method tree.query is not directly picklable by cloudpickle
595
595
under PyPy.
@@ -598,10 +598,10 @@ def _tree_query_parallel_helper(tree, *args, **kwargs):
598
598
599
599
600
600
class KNeighborsMixin :
601
- """Mixin for k-neighbors searches"""
601
+ """Mixin for k-neighbors searches. """
602
602
603
603
def _kneighbors_reduce_func (self , dist , start , n_neighbors , return_distance ):
604
- """Reduce a chunk of distances to the nearest neighbors
604
+ """Reduce a chunk of distances to the nearest neighbors.
605
605
606
606
Callback to :func:`sklearn.metrics.pairwise.pairwise_distances_chunked`
607
607
@@ -851,7 +851,8 @@ def kneighbors_graph(self, X=None, n_neighbors=None, mode="connectivity"):
851
851
852
852
See Also
853
853
--------
854
- NearestNeighbors.radius_neighbors_graph: Computes a graph of neighbors.
854
+ NearestNeighbors.radius_neighbors_graph : Compute the (weighted) graph
855
+ of Neighbors for points in X.
855
856
856
857
Examples
857
858
--------
@@ -901,7 +902,7 @@ def kneighbors_graph(self, X=None, n_neighbors=None, mode="connectivity"):
901
902
902
903
903
904
def _tree_query_radius_parallel_helper (tree , * args , ** kwargs ):
904
- """Helper for the Parallel calls in RadiusNeighborsMixin.radius_neighbors
905
+ """Helper for the Parallel calls in RadiusNeighborsMixin.radius_neighbors.
905
906
906
907
The Cython method tree.query_radius is not directly picklable by
907
908
cloudpickle under PyPy.
@@ -910,10 +911,10 @@ def _tree_query_radius_parallel_helper(tree, *args, **kwargs):
910
911
911
912
912
913
class RadiusNeighborsMixin :
913
- """Mixin for radius-based neighbors searches"""
914
+ """Mixin for radius-based neighbors searches. """
914
915
915
916
def _radius_neighbors_reduce_func (self , dist , start , radius , return_distance ):
916
- """Reduce a chunk of distances to the nearest neighbors
917
+ """Reduce a chunk of distances to the nearest neighbors.
917
918
918
919
Callback to :func:`sklearn.metrics.pairwise.pairwise_distances_chunked`
919
920
0 commit comments