Question

I have a multi dimensional time series data that are the features for action recognition. I have 20 variables representing 3D joint positions, quaternion values, mean, euclidean distance between joints. I have applied kmeans clustering with k=4. After clustering, I want to combine co-occuring cluster id's together such that the data points corresponding to them are also clubbed together by that cluster id. For instance, considering the following cluster indices for 10 data samples,

IDX = [1 1 2 1 3 3 3 2 2 4]'

Let the data be the following where A,B,C,D,E,F,G,H are the 3 feature varaibles where (A-C) represents (x,y,z) coordinate of a particular joint, and D represents the euclidean distance of the joint relative to the head,(E-H) are the quaternion value of the joint. Let the numeric values be the elements. Data =

A   B   C   D    E   F    G   H
a1  b1  c1  d1   e1  f1   g1  h1
a2  b2  c2  d2   e2  f2   g2  h2
a3  b3  c3  d3   e3  f3   g3  h3
a4  b4  c4  d4   e4  f4   g4  h4
a5  b5  c5  d5   e5  f5   g5  h5
a6  b6  c6  d6   e6  f6   g6  h6
a7  b7  c7  d7   e7  f7   g7  h7
a8  b8  c8  d8   e8  f8   g8  h8
a9  b9  c9  d9   e9  f9   g9  h9
a10 b10 c10 d10  e10 f10  g10 h10

Then, the result will be a reduced vector (compressed version of the data) where first 2 rows of data will be represented by the cluster id 1, 3rd row of data by cluster id 2, 4th row = 1, fifth, sixth and 7th rows will be combined and represented by 3,8th&9th row by 2 and last row by 4. Thus, the final data representation becomes a compressed string whose dimensionality and length is also reduced : Compressed_Data = [1 2 1 3 2 4]' . How do I do this mapping and conversion? Thank you in advance.

Was it helpful?

Solution

To compress your index array, IDX, you could try the following:

a = IDX; % for clarity, use a different variable, a
a(find(diff(IDX)==0)+1) = []; % remove repeating elements
Compressed_Data = a;

Alternatively,

Compressed_Data = IDX([1; find(diff(IDX(:))~=0)+1])

Please let me know if this is not what you are looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top