comparison toolboxes/distance_learning/mlr/metricPsi/metricPsiMRR.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function S = metricPsiMRR(q, y, n, pos, neg)
2 %
3 % S = metricPsiMRR(q, y, n, d, pos, neg)
4 %
5 % q = index of the query point
6 % y = the ordering to compute
7 % n = number of points in the data set
8 % pos = indices of relevant results for q
9 % neg = indices of irrelevant results for q
10 %
11 % S is the vector of weights for q
12
13 yp = ismember(y, pos);
14 % Truncate yp after the first 1
15 yp(find(yp,1)+1:end) = 0;
16 NumPOS = sum(yp);
17 PosAfter = NumPOS - cumsum(yp);
18
19 yn = ~yp;
20 NumNEG = sum(yn);
21 NegBefore = cumsum(yn) - yn;
22
23 S = zeros(n,1);
24
25 S(y) = 2 * (yp .* NegBefore - yn .* PosAfter) / (NumNEG * NumPOS);
26
27 end