8000 DOC fix docstring of KMeans based on sklearn guideline (#15754) · scikit-learn/scikit-learn@d5c6c96 · GitHub
[go: up one dir, main page]

Skip to content

Commit d5c6c96

Browse files
cgsavardglemaitre
authored andcommitted
DOC fix docstring of KMeans based on sklearn guideline (#15754)
1 parent 64750e5 commit d5c6c96

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

sklearn/cluster/_k_means.py

+14-13
Original file line numberDiff line numberDiff line change
@@ -654,11 +654,12 @@ class KMeans(TransformerMixin, ClusterMixin, BaseEstimator):
654654
Parameters
655655
----------
656656
657-
n_clusters : int, optional, default: 8
657+
n_clusters : int, default=8
658658
The number of clusters to form as well as the number of
659659
centroids t 10000 o generate.
660660
661-
init : {'k-means++', 'random' or an ndarray}
661+
init : {'k-means++', 'random'} or ndarray of shape \
662+
(n_clusters, n_features), default='k-means++'
662663
Method for initialization, defaults to 'k-means++':
663664
664665
'k-means++' : selects initial cluster centers for k-mean
@@ -671,19 +672,19 @@ class KMeans(TransformerMixin, ClusterMixin, BaseEstimator):
671672
If an ndarray is passed, it should be of shape (n_clusters, n_features)
672673
and gives the initial centers.
673674
674-
n_init : int, default: 10
675+
n_init : int, default=10
675676
Number of time the k-means algorithm will be run with different
676677
centroid seeds. The final results will be the best output of
677678
n_init consecutive runs in terms of inertia.
678679
679-
max_iter : int, default: 300
680+
max_iter : int, default=300
680681
Maximum number of iterations of the k-means algorithm for a
681682
single run.
682683
683-
tol : float, default: 1e-4
684+
tol : float, default=1e-4
684685
Relative tolerance with regards to inertia to declare convergence.
685686
686-
precompute_distances : {'auto', True, False}
687+
precompute_distances : 'auto' or bool, default='auto'
687688
Precompute distances (faster but takes more memory).
688689
689690
'auto' : do not precompute distances if n_samples * n_clusters > 12
@@ -694,15 +695,15 @@ class KMeans(TransformerMixin, ClusterMixin, BaseEstimator):
694695
695696
False : never precompute distances.
696697
697-
verbose : int, default 0
698+
verbose : int, default=0
698699
Verbosity mode.
699700
700-
random_state : int, RandomState instance or None (default)
701+
random_state : int, RandomState instance, default=None
701702
Determines random number generation for centroid initialization. Use
702703
an int to make the randomness deterministic.
703704
See :term:`Glossary <random_state>`.
704705
705-
copy_x : bool, optional
706+
copy_x : bool, default=True
706707
When pre-computing distances it is more numerically accurate to center
707708
the data first. If copy_x is True (default), then the original data is
708709
not modified, ensuring X is C-contiguous. If False, the original data
@@ -711,28 +712,28 @@ class KMeans(TransformerMixin, ClusterMixin, BaseEstimator):
711712
the data mean, in this case it will also not ensure that data is
712713
C-contiguous which may cause a significant slowdown.
713714
714-
n_jobs : int or None, optional (default=None)
715+
n_jobs : int, default=None
715716
The number of jobs to use for the computation. This works by computing
716717
each of the n_init runs in parallel.
717718
718719
``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
719720
``-1`` means using all processors. See :term:`Glossary <n_jobs>`
720721
for more details.
721722
722-
algorithm : "auto", "full" or "elkan", default="auto"
723+
algorithm : {"auto", "full", "elkan"}, default="auto"
723724
K-means algorithm to use. The classical EM-style algorithm is "full".
724725
The "elkan" variation is more efficient by using the triangle
725726
inequality, but currently doesn't support sparse data. "auto" chooses
726727
"elkan" for dense data and "full" for sparse data.
727728
728729
Attributes
729730
----------
730-
cluster_centers_ : array, [n_clusters, n_features]
731+
cluster_centers_ : ndarray of shape (n_clusters, n_features)
731732
Coordinates of cluster centers. If the algorithm stops before fully
732733
converging (see ``tol`` and ``max_iter``), these will not be
733734
consistent with ``labels_``.
734735
735-
labels_ : array, shape (n_samples,)
736+
labels_ : ndarray of shape (n_samples,)
736737
Labels of each point
737738
738739
inertia_ : float

0 commit comments

Comments
 (0)
0