Skip to content
Snippets Groups Projects
Commit 34dfdae4 authored by DIANE's avatar DIANE
Browse files

clusters name

parent 6894c76a
No related branches found
No related tags found
No related merge requests found
...@@ -19,13 +19,6 @@ class Sk_Kmeans: ...@@ -19,13 +19,6 @@ class Sk_Kmeans:
def fit_optimal(self, nclusters): def fit_optimal(self, nclusters):
model = KMeans(n_clusters = nclusters, init = 'k-means++', random_state = 42) model = KMeans(n_clusters = nclusters, init = 'k-means++', random_state = 42)
model.fit(self.x) model.fit(self.x)
yp = model.predict(self.x) yp = model.predict(self.x)+1
num_colors = nclusters clu = [f'cluster#{i}' for i in yp]
colors = ['#' + ''.join([random.choice('0123456789ABCDEF') for _ in range(6)]) for _ in range(num_colors)] return self.x, clu
col = np.array(['#' + ''.join([random.choice('0123456789ABCDEF') for _ in range(6)]) for _ in range(self.x.shape[0])]) \ No newline at end of file
for i in range(nclusters):
ss = np.where(yp==i)
col[ss] = colors[i]
return self.x, col
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment