-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample_IBGR.m
135 lines (71 loc) · 2.73 KB
/
sample_IBGR.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
clc;
clear;
close all;
%% It is a sample code for IBGR based on a fixed group with five member and seven rated items
load('Rating.mat');
NumUser = 5;
NumItem = 7;
Trust = zeros(NumUser,NumUser);
for i = 1:NumUser
U_i = Rating(i,:)>0;
Sum_i = sum(U_i);
for j = 1:NumUser
U_j = Rating(j,:)>0;
Sum_j = sum(U_j);
Intersection = U_i.*U_j;
IntersectionCount_ij = sum(Intersection);
Dist_ij = pdist([Rating(i,:);Rating(j,:)],'euclidean');
Partnership = IntersectionCount_ij/Sum_i;
Distance = 1/(1+Dist_ij);
Trust(i,j) = (2*Partnership*Distance)/(Partnership+Distance);
end
end
Similarity = corr(Rating');
MembersSumSimi = (sum(Similarity))-1;
T = Trust';
MembersSumTrust = (sum(T))-1;
[L,LeaderId] = max (MembersSumSimi+MembersSumTrust);
LeaderImpact = L/(2*(NumUser-1));
MembersRating = zeros(NumUser,NumItem);
for i = 1:NumUser
for k = 1:NumItem
if Rating(i,k)==0
Rating_ik = 1;
else
Rating_ik = Rating(i,k);
end
Influe = 0;
for j = 1:NumUser
if i ~= j
Rating_jk = Rating(j,k);
if j== LeaderId
Weight_ji = (1/2) * (LeaderImpact + (2 * Similarity(i,j) * Trust(i,j)) / (Similarity(i,j) + Trust(i,j)));
else
Weight_ji = (2 * Similarity(i,j) * Trust(i,j)) / (Similarity(i,j) + Trust(i,j));
end
if Rating_jk > 0
Influe = Influe + (Weight_ji * ((Rating_jk - Rating_ik)));
end
end
end
MembersRating(i,k) = Rating_ik + Influe;
end
end
GroupRating = (sum(MembersRating))./NumUser;
[R, Index] = sort(GroupRating,'descend');
RecommendationSize = 3;
Satisfying_Treshould = 3;
S = 0;
for i = 1:NumUser
for k = 1:RecommendationSize
ItemId = Index(k);
if Rating(i,ItemId) ~= 0
Rating_ik = Rating(i,ItemId);
if Rating_ik >= Satisfying_Treshould
S = S + 1;
end
end
end
end
Satisfication = (S / (NumUser * RecommendationSize)) * 100;
disp([' Satisfication :' num2str(Satisfication)]);