how to cluster bit strings using matlab

A= [ 1 0 0 0 0 0 1 1 0,
0 0 0 0 1 1 0 0 1,
1 1 1 1 1 1 1 0 0,
1 1 1 1 1 1 1 0 0,
1 0 0 0 0 0 1 1 0,
0 0 0 0 1 1 0 0 1,
1 1 1 1 1 1 1 1 1]
let A be the binary matrix.. 1 means there is decrease in production and 0 means there is increase in production ..
how will i cluster the same bit strings patterns?
i m working on health care data set[rows= 453 and col = 60] .. 1 represent decrease and 0 represent increase ..can this be possible using loops..
note: order of bits are important..// order dependent

8 件のコメント

KSSV
KSSV 2016 年 5 月 6 日
what do you mean by cluster? You want the positions of 1 and 0?
kumud alok
kumud alok 2016 年 5 月 6 日
i mean similar bit strings should be in one cluster or group or it should be saved in another variable.
KSSV
KSSV 2016 年 5 月 6 日
you can extract 0 and 1 from any matrix using find(mymatrix==1). It will give positions also. Then you can save..
kumud alok
kumud alok 2016 年 5 月 6 日
sir, this function find(mymatrix==1) gives only the location of 1...i got the location ..but what i want is..from matrix A..there are 7 bit strings separated by commas. bit strings 3 and 4 should be one group because pattern are similar ..bit string 1 and 5 shows similar pattern therefore it should be in one cluster(cluster means group of similar things)..
kumud alok
kumud alok 2016 年 5 月 6 日
can u suggest me any clustering algorithm ..
Guillaume
Guillaume 2016 年 5 月 6 日
A = [ 1 0 0 0 0 0 1 1 0, 0 0 0 0 1 1 0 0 1, 1 1 1 1 1 1 1 0 0, 1 1 1 1 1 1 1 0 0, 1 0 0 0 0 0 1 1 0, 0 0 0 0 1 1 0 0 1, 1 1 1 1 1 1 1 1 1]
"there are 7 bit strings separated by commas". No, there isn't. Please learn the matlab syntax, a comma is exactly the same as a space. A is a 1 x 63 vector.
If you were to use a semicolon between each group of 9, then A would be a 7 x 9 matrix:
A = [ 1 0 0 0 0 0 1 1 0; 0 0 0 0 1 1 0 0 1; 1 1 1 1 1 1 1 0 0; 1 1 1 1 1 1 1 0 0; 1 0 0 0 0 0 1 1 0; 0 0 0 0 1 1 0 0 1; 1 1 1 1 1 1 1 1 1]
Or you could put your 7 bit strings into a 1 x 7cell array containing 1 x 9 vectors
A = {[ 1 0 0 0 0 0 1 1 0], [0 0 0 0 1 1 0 0 1], [1 1 1 1 1 1 1 0 0], [1 1 1 1 1 1 1 0 0], [1 0 0 0 0 0 1 1 0], [0 0 0 0 1 1 0 0 1], [1 1 1 1 1 1 1 1 1]}
kumud alok
kumud alok 2016 年 5 月 6 日
okay..thank you so much sir...i m learning matlab..i m working in a project ..my work is to analyse bit string patterns and then apply clustering algorithm..i have applied hierarchical clustering but i m still confused..i just want to asked u about the clustering ..and distance measure also..which similarity measure used i should either hamming or lavenstein..please help me..
Walter Roberson
Walter Roberson 2016 年 5 月 6 日
The original code used
A= [ 1 0 0 0 0 0 1 1 0,
0 0 0 0 1 1 0 0 1,
1 1 1 1 1 1 1 0 0,
and so on. MATLAB does know to treat the end of line line a semi-colon in that case.

サインインしてコメントする。

 採用された回答

Guillaume
Guillaume 2016 年 5 月 6 日

0 投票

It sounds like you just want to identify all identical 'bit strings' and assign them the same ID. This can easily be achieved with unique.
First, let's change A into something useful, since as mentioned in the comment to your question A is not "7 bit strings separated by commas", matlab ignores the commas. While we're at it, let's give the variable a name that has meaning:
A = [ 1 0 0 0 0 0 1 1 0, 0 0 0 0 1 1 0 0 1, 1 1 1 1 1 1 1 0 0, 1 1 1 1 1 1 1 0 0, 1 0 0 0 0 0 1 1 0, 0 0 0 0 1 1 0 0 1, 1 1 1 1 1 1 1 1 1]
bitstreams = reshape(A, 9, [])'; %reshape A into an n x 9 array
To give a unique ID to each identical bit stream we can simply use the third return value of unique, with the 'rows' option to the unique to consider each row as a complete object.
[~, ~, id] = unique(bitstreams, 'rows', 'stable') %stable optional
This returns
id = [1; 2; 3; 3; 1; 2; 4]
where you can see that the 1st and 5th bitstream have been assigned id 1, the 2nd and 6th id 2, the 3rd and 4th id 3, and the last one id 4.

1 件のコメント

kumud alok
kumud alok 2016 年 5 月 9 日
thank u so much sir...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

タグ

タグが未入力です。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by