Commit 0774ae544ea66b7220b6bc2d60eaeb992aac2c40
1 parent
e72cf05267
Exists in
master
Fixed issues
Showing 1 changed file with 6 additions and 6 deletions Side-by-side Diff
volia/clustering_modules/kmeans_multidistance.py
... | ... | @@ -3,7 +3,7 @@ |
3 | 3 | from abstract_clustering import AbstractClustering |
4 | 4 | from KMeans_Multidistance.KMeans_Class import KMeans |
5 | 5 | from random import seed |
6 | -from random import random | |
6 | +from random import randint | |
7 | 7 | import numpy as np |
8 | 8 | from sklearn.metrics import pairwise_distances |
9 | 9 | |
... | ... | @@ -61,7 +61,7 @@ |
61 | 61 | |
62 | 62 | # Compute seeds before using seeds |
63 | 63 | seed() |
64 | - self.seeds = [random() for i in range(ninit)] | |
64 | + self.seeds = [randint(1, 100000) for i in range(ninit)] | |
65 | 65 | |
66 | 66 | # Learning k-means model |
67 | 67 | results = [] |
... | ... | @@ -70,7 +70,7 @@ |
70 | 70 | maxiter=maxiter, |
71 | 71 | distance=self.distance, |
72 | 72 | record_heterogeneity=[], |
73 | - verbose=True, | |
73 | + verbose=debug, | |
74 | 74 | seed=self.seeds[i]) |
75 | 75 | centroids, closest_cluster = model.fit(features) |
76 | 76 | |
... | ... | @@ -92,7 +92,7 @@ |
92 | 92 | }) |
93 | 93 | losses = [result["loss"] for result in results] |
94 | 94 | best = results[losses.index(min(losses))] |
95 | - self.kmeans_model = results[best]["model"] | |
96 | - self.centroids = results[best]["centroids"] | |
97 | - self.seed = results[best]["seed"] | |
95 | + self.kmeans_model = best["model"] | |
96 | + self.centroids = best["centroids"] | |
97 | + self.seed = best["seed"] |