comparison toolboxes/distance_learning/mlr/metricPsi/metricPsiPO.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 = metricPsiPO(q, y, n, pos, neg)
2 %
3 % S = metricPsiPO(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 NumPOS = sum(yp);
15 PosAfter = NumPOS - cumsum(yp);
16
17 yn = ~yp;
18 NumNEG = sum(yn);
19 NegBefore = cumsum(yn) - yn;
20
21 S = zeros(n,1);
22
23 S(y) = 2 * (yp .* NegBefore - yn .* PosAfter) / (NumNEG * NumPOS);
24
25 end