How to find similar users to a target user?

1 ビュー (過去 30 日間)
lucksBi
lucksBi 2018 年 8 月 10 日
コメント済み: lucksBi 2018 年 8 月 11 日
Hi all.
I have an example array (which contains 8 users). I have calculated similarity value for all the users who do not have a value '1' except for themselves. Like in example array, 4 is the only user who do not have a value of 1 for any other user expect for himself (as shown in array 'a'). So i have calculated Similarity of 4 with all other users using some mathematics. Which results in Similarity array:
example= [1,1,1,0,0,0,0,0;0,1,1,1,0,0,0,0;0,0,1,0,1,0,0,0;0,0,0,1,0,0,0,0;0,0,0,0,1,1,0,0;0,0,0,0,0,1,1,1;1,0,0,0,1,0,1,1;0,0,0,1,0,0,0,1]
Similarity = {1;0.8;1;0.9;0.96;1;-0.8}
a= [4]
In similarity array, 1 is similarity of 4 with 1, 0.8 is for 4 and 2, 1 is for 4 and 4 and 3, 0.9 is for 4 and 5 and so on until user 8.
Now i want to extract the users whose similarity with 4 is greater than 0. Like here user 8 has value less than 0, so it will be eliminated and result will look like this: (containing all the similar users)
result ={1,2,3,5,6,7}
And similarly how we can perform this if there are more numbers in array 'a' along with 4. I hope my question is clear.
Thanks in anticipation.

採用された回答

Paul Siefert
Paul Siefert 2018 年 8 月 10 日
You can find values above 0 with the "find" function (type in command window: doc find). To search inside cells you can "cell2mat" before that or do it in a loop.
In oder to process more persons you better use correct indexing. You could create a cell with size of number of persons and save Similarity values inside the corresponding cells. Then you can loop though the length of a using the values of a.
a = [4 6];
Similarity = cell(2,8);
Similarity{1,a(1)} = {1;0.8;1;1;0.9;0.96;1;-0.8};
Similarity{1,a(2)} = {0.2;0.6;-1;0.4;0.84;-0.96;-0.68;0.7};
for i = 1:length(a)
Person = a(i);
Similarity{2,Person} = find(cell2mat(Similarity{1,Person}) > 0);
end
In this example you create a Similarity cell, the first row is for Similarity values, the second for finding values above 0.
The loop runs from 1 to the length of you a array, the person number is defined as a(i). This is used to save the values to the second row.
Hope this helps Paul
  1 件のコメント
lucksBi
lucksBi 2018 年 8 月 11 日
Thanks alot for help.

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

その他の回答 (0 件)

カテゴリ

Find more on Cell Arrays in Help Center and File Exchange

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by