views:

22

answers:

0

Hi,

I am wondering how can I do clustering of time series data. I understand if the data is a point. But I do not know how to cluster if the data is time series with 1XM where M is the data length. Especially the part on how to compute new mean of the cluster for time series data.

My X matrix will be N X M where N is number of time series and M is data length as mentioned.

If i have a set of label time series , I want to use K mean algorithm to check whether I will get back the similar label or not.

Can someone guide me how to do it ?

for example using this k means matlab code. how do I modify so I can use it for time series data ? http://www.mathworks.cn/matlabcentral/fileexchange/19344-efficient-k-means-clustering-using-jit

Also, I wish to use different distance measure besides euclidean distance.

to Give better illustration of my doubt here is the code I modified for time series

===========================================

% Check if second input is centroids if ~isscalar(k) c=k; k=size(c,1); else c=X(ceil(rand(k,1)*n),:); % assign centroid randonly at start end

% allocating variables g0=ones(n,1);

gIdx=zeros(n,1); D=zeros(n,k);

% Main loop converge if previous partition is the same as current while

any(g0~=gIdx) %

disp(sum(g0~=gIdx))

g0=gIdx;

% Loop for each centroid

for t=1:k

  %  d=zeros(n,1);

   % Loop for each dimension

      for s=1:n

        D(s,t) = sqrt(sum((X(s,:)-c(t,:)).^2)); 
    end

end % Partition data to closest centroids

   [z,gIdx]=min(D,[],2);
% Update centroids using means of partitions

  for t=1:k

  c(t,:)=mean(X(gIdx==t,:));  % Is this how we calculate new mean of

the time series?

end end