From 9c629560db9c09fa382b72de579ace466cca20fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20H=C3=B6rsch?= Date: Mon, 24 Sep 2018 18:35:11 +0200 Subject: [PATCH] cluster_network: Adjust n_init, maxiter and tol parameters of KMeans By changing the parameters by several orders of magnitude, we ensure to recover consistently the same results. --- scripts/cluster_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cluster_network.py b/scripts/cluster_network.py index f60d9881..ed55c24a 100644 --- a/scripts/cluster_network.py +++ b/scripts/cluster_network.py @@ -126,7 +126,7 @@ def busmap_for_n_clusters(n, n_clusters): if len(x) == 1: return pd.Series(prefix + '0', index=x.index) weight = weighting_for_country(n, x) - return prefix + busmap_by_kmeans(n, weight, n_clusters[x.name], buses_i=x.index) + return prefix + busmap_by_kmeans(n, weight, n_clusters[x.name], buses_i=x.index, n_init=1000, max_iter=30000, tol=1e-6) return n.buses.groupby(['country', 'sub_network'], group_keys=False).apply(busmap_for_country) def plot_busmap_for_n_clusters(n, n_clusters=50):