Example #1
0
File: NDCG.java Project: apnn/apnn
 /**
  * @param optimalResult
  * @param retrievedResult
  * @return the Discounted Cumulative Gain for the retrieved NNs vs the optimal NNs (ground truth)
  *     for the given suspicious document.
  */
 private double dcg(GTQuery optimalResult, ResultQuery retrievedResult, int k) {
   double dcg = 0;
   for (int position = 0; position < k && position < retrievedResult.size(); position++) {
     SourceDocument document = retrievedResult.retrievedDocuments.get(position);
     // positions count from 0
     SourceDocument gt = optimalResult.relevantDocuments.get(document.queryid);
     if (gt != null) {
       if (document.position == 1) {
         dcg += relevanceGrade(document.position, k);
       } else {
         dcg += relevanceGrade(document.position, k) / MathTools.log2(document.position);
       }
     }
   }
   return dcg;
 }
Example #2
0
 @Override
 public int hashCode() {
   return MathTools.hashCode(run.hashCode(), queryid);
 }