From 62b6b42e27a4972397e94fdbb03e74ac3f5f1244 Mon Sep 17 00:00:00 2001 From: Joe Zhao Date: Tue, 12 May 2015 13:30:55 +0800 Subject: misc --- model/rankaccu.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'model/rankaccu.cpp') diff --git a/model/rankaccu.cpp b/model/rankaccu.cpp index 73b5d18..ba8aee6 100644 --- a/model/rankaccu.cpp +++ b/model/rankaccu.cpp @@ -75,20 +75,21 @@ void rank_accu(DataList &D,const vector pred) unsigned long n = D.getSize(); vector orig_rank(n),pred_rank(n),C(n); vector orig(n); + vector &dat = D.getData(); int i,j; - for (i=0;irank; + orig[i]=dat[i]->rank; } int cnt=0; double accu_nDCG=0; double accu_AP=0; i=j=0; - while (iqid!=D.getData()[i+1]->qid) + if ((i+1 == dat.size())|| dat[i]->qid!=dat[i+1]->qid) { double Y=0,Z=0; double AP=0; @@ -117,24 +118,25 @@ void rank_CMC(DataList &D,const std::vector pred,CMC & cmc) { unsigned long n = D.getSize(); vector orig_rank(n),pred_rank(n); vector orig(n); + vector &dat = D.getData(); int i,j; - for (i=0;irank; + orig[i]=dat[i]->rank; } int cnt=0; i=j=0; - while (iqid!=D.getData()[i+1]->qid) + if ((i+1 == dat.size())|| dat[i]->qid!=dat[i+1]->qid) { ranksort(j,i,pred_rank,pred,orig); for (int k=j;k<=i;++k) if (orig[pred_rank[k]]>0) { - cout<qid<<" "<