8000 DOC ensures DBSCAN docstring passes numpydoc validation (#20375) · scikit-learn/scikit-learn@de52d4d · GitHub
[go: up one dir, main page]

Skip to content

Commit de52d4d

Browse files
fbiduijpulidosglemaitre
authored
DOC ensures DBSCAN docstring passes numpydoc validation (#20375)
Co-authored-by: Iván Pulido <ivanpulido@protonmail.com> Co-authored-by: Guillaume Lemaitre <g.lemaitre58@gmail.com>
1 parent 03ab582 commit de52d4d

File tree

2 files changed

+22
-24
lines changed

2 files changed

+22
-24
lines changed

maint_tools/test_docstrings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"ColumnTransformer",
3030
"ComplementNB",
3131
"CountVectorizer",
32-
"DBSCAN",
3332
"DecisionTreeClassifier",
3433
"DecisionTreeRegressor",
3534
"DictVectorizer",

sklearn/cluster/_dbscan.py

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ class DBSCAN(ClusterMixin, BaseEstimator):
183183
The number of samples (or total weight) in a neighborhood for a point
184184
to be considered as a core point. This includes the point itself.
185185
186-
metric : string, or callable, default='euclidean'
186+
metric : str, or callable, default='euclidean'
187187
The metric to use when calculating distance between instances in a
188188
feature array. If metric is a string or callable, it must be one of
189189
the options allowed by :func:`sklearn.metrics.pairwise_distances` for
@@ -239,18 +239,6 @@ class DBSCAN(ClusterMixin, BaseEstimator):
239239
240240
.. versionadded:: 0.24
241241
242-
Examples
243-
--------
244-
>>> from sklearn.cluster import DBSCAN
245-
>>> import numpy as np
246-
>>> X = np.array([[1, 2], [2, 2], [2, 3],
247-
... [8, 7], [8, 8], [25, 80]])
248-
>>> clustering = DBSCAN(eps=3, min_samples=2).fit(X)
249-
>>> clustering.labels_
250-
array([ 0, 0, 0, 1, 1, -1])
251-
>>> clustering
252-
DBSCAN(eps=3, min_samples=2)
253-
254242
See Also
255243
--------
256244
OPTICS : A similar clustering at multiple values of eps. Our implementation
@@ -289,6 +277,18 @@ class DBSCAN(ClusterMixin, BaseEstimator):
289277
Schubert, E., Sander, J., Ester, M., Kriegel, H. P., & Xu, X. (2017).
290278
DBSCAN revisited, revisited: why and how you should (still) use DBSCAN.
291279
ACM Transactions on Database Systems (TODS), 42(3), 19.
280+
281+
Examples
282+
--------
283+
>>> from sklearn.cluster import DBSCAN
284+
>>> import numpy as np
285+
>>> X = np.array([[1, 2], [2, 2], [2, 3],
286+
... [8, 7], [8, 8], [25, 80]])
287+
>>> clustering = DBSCAN(eps=3, min_samples=2).fit(X)
288+
>>> clustering.labels_
289+
array([ 0, 0, 0, 1, 1, -1])
290+
>>> clustering
291+
DBSCAN(eps=3, min_samples=2)
292292
"""
293293

294294
def __init__(
@@ -323,19 +323,19 @@ def fit(self, X, y=None, sample_weight=None):
323323
``metric='precomputed'``. If a sparse matrix is provided, it will
324324
be converted into a sparse ``csr_matrix``.
325325
326+
y : Ignored
327+
Not used, present here for API consistency by convention.
328+
326329
sample_weight : array-like of shape (n_samples,), default=None
327330
Weight of each sample, such that a sample with a weight of at least
328331
``min_samples`` is by itself a core sample; a sample with a
329332
negative weight may inhibit its eps-neighbor from being core.
330333
Note that weights are absolute, and default to 1.
331334
332-
y : Ignored
333-
Not used, present here for API consistency by convention.
334-
335335
Returns
336336
-------
337-
self
338-
337+
self : object
338+
Returns a fitted instance of self.
339339
"""
340340
X = self._validate_data(X, accept_sparse="csr")
341341

@@ -394,8 +394,7 @@ def fit(self, X, y=None, sample_weight=None):
394394
return self
395395

396396
def fit_predict(self, X, y=None, sample_weight=None):
397-
"""Perform DBSCAN clustering from features or distance matrix,
398-
and return cluster labels.
397+
"""Compute clusters from a data or distance matrix and predict labels.
399398
400399
Parameters
401400
----------
@@ -405,15 +404,15 @@ def fit_predict(self, X, y=None, sample_weight=None):
405404
``metric='precomputed'``. If a sparse matrix is provided, it will
406405
be converted into a sparse ``csr_matrix``.
407406
407+
y : Ignored
408+
Not used, present here for API consistency by convention.
409+
408410
sample_weight : array-like of shape (n_samples,), default=None
409411
Weight of each sample, such that a sample with a weight of at least
410412
``min_samples`` is by itself a core sample; a sample with a
411413
negative weight may inhibit its eps-neighbor from being core.
412414
Note that weights are absolute, and default to 1.
413415
414-
y : Ignored
415-
Not used, present here for API consistency by convention.
416-
417416
Returns
418417
-------
419418
labels : ndarray of shape (n_samples,)

0 commit comments

Comments
 (0)
0