From 0774ae544ea66b7220b6bc2d60eaeb992aac2c40 Mon Sep 17 00:00:00 2001 From: quillotm Date: Tue, 24 Aug 2021 12:31:59 +0200 Subject: [PATCH] Fixed issues --- volia/clustering_modules/kmeans_multidistance.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/volia/clustering_modules/kmeans_multidistance.py b/volia/clustering_modules/kmeans_multidistance.py index 47fe159..2d2971d 100644 --- a/volia/clustering_modules/kmeans_multidistance.py +++ b/volia/clustering_modules/kmeans_multidistance.py @@ -3,7 +3,7 @@ import pickle from abstract_clustering import AbstractClustering from KMeans_Multidistance.KMeans_Class import KMeans from random import seed -from random import random +from random import randint import numpy as np from sklearn.metrics import pairwise_distances @@ -61,7 +61,7 @@ class kmeansMultidistance(): # Compute seeds before using seeds seed() - self.seeds = [random() for i in range(ninit)] + self.seeds = [randint(1, 100000) for i in range(ninit)] # Learning k-means model results = [] @@ -70,7 +70,7 @@ class kmeansMultidistance(): maxiter=maxiter, distance=self.distance, record_heterogeneity=[], - verbose=True, + verbose=debug, seed=self.seeds[i]) centroids, closest_cluster = model.fit(features) @@ -92,6 +92,6 @@ class kmeansMultidistance(): }) losses = [result["loss"] for result in results] best = results[losses.index(min(losses))] - self.kmeans_model = results[best]["model"] - self.centroids = results[best]["centroids"] - self.seed = results[best]["seed"] + self.kmeans_model = best["model"] + self.centroids = best["centroids"] + self.seed = best["seed"] -- 1.8.2.3