-
Notifications
You must be signed in to change notification settings - Fork 1
/
MMR_Implementation.m
49 lines (40 loc) · 1.34 KB
/
MMR_Implementation.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
%{
Run MMR algorithm.
Input: relevance scores,covariance matrix
Output:
The re-ranking list
The metrics: Recall@1-5,Precision@1-5,NDCG@5,MRR@5
%}
load('Covariance')
Output=[];
rank=15;
for l=0.1:0.1:0.9
result=zeros(2,4);
for i=101:150
%if isempty(Result{i})==0
path=strcat('c:\WT10G\',num2str(i),'.txt');
data=load(path);
scores=data(:,1);
relevance=data(:,2);
scores=scores.^2;
scores=(scores-min(scores))/(max(scores)-min(scores))*0.5+0.5;
covarianceMatrix=Covariance{i-100};
index=2:rank;
select=1;
for k=2:10
value=ones(1,rank)*-10;
for j=index
action=[select,j];
value(j)=l*scores(j)-(1-l)*max(covarianceMatrix(j,select));
end
act=find(value==max(value),1);
select=[select,act]
index(find(index==act))=[];
end
result(1,:)=result(1,:)+metric(ChangeAction2RankList(select(1:5),200),relevance);
%relevance(select(1:5))=[];
result(2,:)=result(2,:)+metric(ChangeAction2RankList(select(6:10),195),relevance);
%end
end
Output=[Output;result./50];
end