You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Getting different results on the same data set #17
for j in range(5):
ksc = KShapeClusteringCPU(num_clusters, centroid_init='zero', max_iter=100, n_jobs=-1)
ksc.fit(univariate_ts_datasets)
labels = ksc.labels_ # or ksc.predict(univariate_ts_datasets)
cluster_centroids = ksc.centroids_
print(labels)
My understanding is that there's nothing random in the algo since I set the centroid init to be zero. But I get different results, e.g. sometimes the first ts and second ts belong to the same cluster and sometimes they don't
Hi James,
K-Shape indeed has randomness. In your code, you set centroid init to zero, but k-Shape will randomly assign time series into clusters as an initialization. Please check here:
Also, when a cluster becomes empty during iterations, k-Shape will randomly assign a time series to that empty cluster. If you want to have a deterministic result, you need to set a random seed. I hope my answer can help.
Best,
Haojun
Activity
HaojunLi commentedon Sep 18, 2024
Hi James,

K-Shape indeed has randomness. In your code, you set centroid init to zero, but k-Shape will randomly assign time series into clusters as an initialization. Please check here:
Also, when a cluster becomes empty during iterations, k-Shape will randomly assign a time series to that empty cluster. If you want to have a deterministic result, you need to set a random seed. I hope my answer can help.
Best,
Haojun