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.
This commit is contained in:
Jonas Hörsch 2018-09-24 18:35:11 +02:00
parent 1678f319d8
commit 9c629560db

View File

@ -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):