Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5de9aff

Browse files
cynthias13wglemaitre
authored andcommitted
DOC link to example explaining init usage in KMeans (#26981)
Co-authored-by: Guillaume Lemaitre <[email protected]>
1 parent e4fd1f4 commit 5de9aff

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

sklearn/cluster/_kmeans.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,22 +1224,25 @@ class KMeans(_BaseKMeans):
12241224
(n_clusters, n_features), default='k-means++'
12251225
Method for initialization:
12261226
1227-
'k-means++' : selects initial cluster centroids using sampling based on
1228-
an empirical probability distribution of the points' contribution to the
1229-
overall inertia. This technique speeds up convergence. The algorithm
1230-
implemented is "greedy k-means++". It differs from the vanilla k-means++
1231-
by making several trials at each sampling step and choosing the best centroid
1232-
among them.
1227+
* 'k-means++' : selects initial cluster centroids using sampling \
1228+
based on an empirical probability distribution of the points' \
1229+
contribution to the overall inertia. This technique speeds up \
1230+
convergence. The algorithm implemented is "greedy k-means++". It \
1231+
differs from the vanilla k-means++ by making several trials at \
1232+
each sampling step and choosing the best centroid among them.
12331233
1234-
'random': choose `n_clusters` observations (rows) at random from data
1235-
for the initial centroids.
1234+
* 'random': choose `n_clusters` observations (rows) at random from \
1235+
data for the initial centroids.
12361236
1237-
If an array is passed, it should be of shape (n_clusters, n_features)
1237+
* If an array is passed, it should be of shape (n_clusters, n_features)\
12381238
and gives the initial centers.
12391239
1240-
If a callable is passed, it should take arguments X, n_clusters and a
1240+
* If a callable is passed, it should take arguments X, n_clusters and a\
12411241
random state and return an initialization.
12421242
1243+
For an example of how to use the different `init` strategy, see the example
1244+
entitled :ref:`sphx_glr_auto_examples_cluster_plot_kmeans_digits.py`.
1245+
12431246
n_init : 'auto' or int, default=10
12441247
Number of times the k-means algorithm is run with different centroid
12451248
seeds. The final results is the best output of `n_init` consecutive runs

0 commit comments

Comments
 (0)