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

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:cc4b1211e677
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