TheDatumOrg / kshape-python

Python implementation of k-Shape
MIT License
330 stars 105 forks source link

Cluster centers equal to 0 #1

Closed wfphyl closed 7 years ago

wfphyl commented 7 years ago

Hello Mic92,

I was trying to run your code, however the results of clusters are sometimes has 0 centers. When the cluster_num = 2, it is fine. However, when the cluster_num = 4, it has two 0 centroid.

time_series = [[1,2,3,4], [0,1,2,3], [0,1,2,3], [1,2,2,3],[2,2,2,2],[9,9,8,7],[2,2,1,1]]

cluster_num =4 clusters = _kshape(zscore(time_series), cluster_num) clusters (array([1, 1, 1, 1, 2, 2, 2]), array([[ 0. , 0. , 0. , 0. ], [-1.2222319 , -0.35269008, 0.52140717, 1.05351481], [-0.56324856, -1.1229572 , 0.83705112, 0.84915464], [ 0. , 0. , 0. , 0. ]]))

Mic92 commented 7 years ago

All your time series got assigned to the second and the third centroid. I just implemented the algorithm as it were described in the paper and the provided Matlab code. It is a property of the algorithm to leave non-assignable clusters empty. If you think this is a bug, please confirm this is a derivation from the original implementation.