Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
clusterCenters.append(currentMean)
if clusterMethod == 'k_means':
from sklearn.cluster import KMeans
k_means = KMeans(
n_clusters=n_clusters,
max_iter=1000,
n_init=n_iter,
tol=1e-4)
clusterOrder = k_means.fit_predict(candidates)
clusterCenters = k_means.cluster_centers_
elif clusterMethod == 'k_medoids':
from tsam.utils.k_medoids_exact import KMedoids
k_medoid = KMedoids(n_clusters=n_clusters, solver=solver)
clusterOrder = k_medoid.fit_predict(candidates)
clusterCenters = k_medoid.cluster_centers_
#
elif clusterMethod == 'hierarchical':
from sklearn.cluster import AgglomerativeClustering
clustering = AgglomerativeClustering(
n_clusters=n_clusters, linkage='ward')
clusterOrder = clustering.fit_predict(candidates)
from sklearn.metrics.pairwise import euclidean_distances
# set cluster center as medoid
clusterCenters = []
for clusterNum in np.unique(clusterOrder):