annotate 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
rev   line source
wolffd@0 1 function S = metricPsiMRR(q, y, n, pos, neg)
wolffd@0 2 %
wolffd@0 3 % S = metricPsiMRR(q, y, n, d, pos, neg)
wolffd@0 4 %
wolffd@0 5 % q = index of the query point
wolffd@0 6 % y = the ordering to compute
wolffd@0 7 % n = number of points in the data set
wolffd@0 8 % pos = indices of relevant results for q
wolffd@0 9 % neg = indices of irrelevant results for q
wolffd@0 10 %
wolffd@0 11 % S is the vector of weights for q
wolffd@0 12
wolffd@0 13 yp = ismember(y, pos);
wolffd@0 14 % Truncate yp after the first 1
wolffd@0 15 yp(find(yp,1)+1:end) = 0;
wolffd@0 16 NumPOS = sum(yp);
wolffd@0 17 PosAfter = NumPOS - cumsum(yp);
wolffd@0 18
wolffd@0 19 yn = ~yp;
wolffd@0 20 NumNEG = sum(yn);
wolffd@0 21 NegBefore = cumsum(yn) - yn;
wolffd@0 22
wolffd@0 23 S = zeros(n,1);
wolffd@0 24
wolffd@0 25 S(y) = 2 * (yp .* NegBefore - yn .* PosAfter) / (NumNEG * NumPOS);
wolffd@0 26
wolffd@0 27 end