Skip to content

Commit c8b5f89

Browse files
Yinglrrth
authored andcommitted
DOC Improved docstrings for MiniBatchKMeans (scikit-learn#15455)
1 parent 709ddfe commit c8b5f89

File tree

1 file changed

+20
-18
lines changed

1 file changed

+20
-18
lines changed

sklearn/cluster/_k_means.py

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,8 @@ def _mini_batch_convergence(model, iteration_idx, n_iter, tol,
13251325

13261326

13271327
class MiniBatchKMeans(KMeans):
1328-
"""Mini-Batch K-Means clustering
1328+
"""
1329+
Mini-Batch K-Means clustering.
13291330
13301331
Read more in the :ref:`User Guide <mini_batch_kmeans>`.
13311332
@@ -1356,10 +1357,10 @@ class MiniBatchKMeans(KMeans):
13561357
batch_size : int, optional, default: 100
13571358
Size of the mini batches.
13581359
1359-
verbose : boolean, optional
1360+
verbose : bool, optional
13601361
Verbosity mode.
13611362
1362-
compute_labels : boolean, default=True
1363+
compute_labels : bool, default=True
13631364
Compute label assignment and inertia for the complete dataset
13641365
once the minibatch optimization has converged in fit.
13651366
@@ -1419,6 +1420,17 @@ class MiniBatchKMeans(KMeans):
14191420
defined as the sum of square distances of samples to their nearest
14201421
neighbor.
14211422
1423+
See Also
1424+
--------
1425+
KMeans
1426+
The classic implementation of the clustering method based on the
1427+
Lloyd's algorithm. It consumes the whole set of input data at each
1428+
iteration.
1429+
1430+
Notes
1431+
-----
1432+
See https://www.eecs.tufts.edu/~dsculley/papers/fastkmeans.pdf
1433+
14221434
Examples
14231435
--------
14241436
>>> from sklearn.cluster import MiniBatchKMeans
@@ -1448,19 +1460,6 @@ class MiniBatchKMeans(KMeans):
14481460
[1.12195122, 1.3902439 ]])
14491461
>>> kmeans.predict([[0, 0], [4, 4]])
14501462
array([1, 0], dtype=int32)
1451-
1452-
See also
1453-
--------
1454-
1455-
KMeans
1456-
The classic implementation of the clustering method based on the
1457-
Lloyd's algorithm. It consumes the whole set of input data at each
1458-
iteration.
1459-
1460-
Notes
1461-
-----
1462-
See https://www.eecs.tufts.edu/~dsculley/papers/fastkmeans.pdf
1463-
14641463
"""
14651464

14661465
def __init__(self, n_clusters=8, init='k-means++', max_iter=100,
@@ -1489,12 +1488,15 @@ def fit(self, X, y=None, sample_weight=None):
14891488
if the given data is not C-contiguous.
14901489
14911490
y : Ignored
1492-
not used, present here for API consistency by convention.
1491+
Not used, present here for API consistency by convention.
14931492
14941493
sample_weight : array-like, shape (n_samples,), optional
14951494
The weights for each observation in X. If None, all observations
1496-
are assigned equal weight (default: None)
1495+
are assigned equal weight (default: None).
14971496
1497+
Returns
1498+
-------
1499+
self
14981500
"""
14991501
random_state = check_random_state(self.random_state)
15001502
X = check_array(X, accept_sparse="csr", order='C',

0 commit comments

Comments
 (0)