@@ -34,7 +34,7 @@ def get_clusters_by_elbow(X, list_clusters=None, **kwargs):
34
34
list_clusters = DEFAULT_LIST_CLUSTERS
35
35
wcss = []
36
36
for n_c in list_clusters :
37
- kmeans = KMeans (n_clusters = n_c )
37
+ kmeans = KMeans (n_clusters = n_c , n_init = "auto" )
38
38
kmeans .fit (X = X )
39
39
wcss .append (kmeans .inertia_ )
40
40
x1 , y1 = 2 , wcss [0 ]
@@ -158,7 +158,7 @@ def get_clusters_by_silhouette_score(X, list_clusters=None, **kwargs):
158
158
sil_max = 0
159
159
sil_max_clusters = 2
160
160
for n_clusters in list_clusters :
161
- model = KMeans (n_clusters = n_clusters )
161
+ model = KMeans (n_clusters = n_clusters , n_init = "auto" )
162
162
labels = model .fit_predict (X )
163
163
sil_score = metrics .silhouette_score (X , labels )
164
164
if sil_score > sil_max :
@@ -176,7 +176,7 @@ def get_clusters_by_davies_bouldin(X, list_clusters=None, **kwargs):
176
176
list_clusters = DEFAULT_LIST_CLUSTERS
177
177
list_dbs = []
178
178
for n_clusters in list_clusters :
179
- model = KMeans (n_clusters = n_clusters )
179
+ model = KMeans (n_clusters = n_clusters , n_init = "auto" )
180
180
labels = model .fit_predict (X )
181
181
db_score = metrics .davies_bouldin_score (X , labels )
182
182
list_dbs .append (db_score )
@@ -192,7 +192,7 @@ def get_clusters_by_calinski_harabasz(X, list_clusters=None, **kwargs):
192
192
list_clusters = DEFAULT_LIST_CLUSTERS
193
193
list_chs = []
194
194
for n_clusters in list_clusters :
195
- model = KMeans (n_clusters = n_clusters )
195
+ model = KMeans (n_clusters = n_clusters , n_init = "auto" )
196
196
labels = model .fit_predict (X )
197
197
ch_score = metrics .calinski_harabasz_score (X , labels )
198
198
list_chs .append (ch_score )
0 commit comments