How to find similar users to a target user?

1 Ansicht (letzte 30 Tage)
lucksBi
lucksBi am 10 Aug. 2018
Kommentiert: lucksBi am 11 Aug. 2018
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.

Akzeptierte Antwort

Paul Siefert
Paul Siefert am 10 Aug. 2018
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

Weitere Antworten (0)

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by