test_class.declarator: prefs = SimplePreferenceData.load(Stream.of(
              tuple("a", "A", 1.0),
              tuple("a", "B", 1.0),
              tuple("a", "C", 1.0),
              tuple("a", "D", 1.0),
              tuple("b", "A", 1.0)
      ))
test_class.modifier: private final
test_class.original_string: private final PreferenceData<String, String> prefs = SimplePreferenceData.load(Stream.of(
              tuple("a", "A", 1.0),
              tuple("a", "B", 1.0),
              tuple("a", "C", 1.0),
              tuple("a", "D", 1.0),
              tuple("b", "A", 1.0)
      ));
test_class.type: PreferenceData<String, String>
test_class.var_name: prefs
test_class.declarator: ap = new AveragePrecision<>(5, new BinaryRelevanceModel<>(false, prefs, 1.0))
test_class.modifier: private final
test_class.original_string: private final RecommendationMetric<String, String> ap = new AveragePrecision<>(5, new BinaryRelevanceModel<>(false, prefs, 1.0));
test_class.type: RecommendationMetric<String, String>
test_class.var_name: ap
test_class.file: RankSys-metrics/src/test/java/es/uam/eps/ir/ranksys/metrics/basic/AveragePrecisionTest.java
test_class.identifier: AveragePrecisionTest
test_case.body: @Test
      public void testB() {
          Recommendation<String, String> recB = new Recommendation<>("b", Arrays.asList(
                  Tuples.tuple("L", 8.0),
                  Tuples.tuple("M", 7.0),
                  Tuples.tuple("N", 6.0),
                  Tuples.tuple("O", 5.0),
                  Tuples.tuple("P", 4.0),
                  Tuples.tuple("Q", 3.0),
                  Tuples.tuple("B", 2.0),
                  Tuples.tuple("C", 1.0),
                  Tuples.tuple("R", 0.0)
          ));
  
          Assert.assertEquals(0.0, ap.evaluate(recB), 0.0);
      }
test_case.class_method_signature: AveragePrecisionTest.testB()
test_case.full_signature: @Test public void testB()
test_case.identifier: testB
test_case.invocations: asList tuple tuple tuple tuple tuple tuple tuple tuple tuple assertEquals evaluate
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testB()
focal_class.declarator: relModel
focal_class.modifier: private final
focal_class.original_string: private final IdealRelevanceModel<U, I> relModel;
focal_class.type: IdealRelevanceModel<U, I>
focal_class.var_name: relModel
focal_class.declarator: cutoff
focal_class.modifier: private final
focal_class.original_string: private final int cutoff;
focal_class.type: int
focal_class.var_name: cutoff
focal_class.file: RankSys-metrics/src/main/java/es/uam/eps/ir/ranksys/metrics/basic/AveragePrecision.java
focal_class.identifier: AveragePrecision
focal_class.class_method_signature: AveragePrecision.AveragePrecision(int cutoff, IdealRelevanceModel<U, I> relevanceModel)
focal_class.full_signature: public  AveragePrecision(int cutoff, IdealRelevanceModel<U, I> relevanceModel)
focal_class.identifier: AveragePrecision
focal_class.modifiers: public
focal_class.parameters: (int cutoff, IdealRelevanceModel<U, I> relevanceModel)
focal_class.signature:  AveragePrecision(int cutoff, IdealRelevanceModel<U, I> relevanceModel)
focal_class.class_method_signature: AveragePrecision.evaluate(Recommendation<U, I> recommendation)
focal_class.full_signature: @Override public double evaluate(Recommendation<U, I> recommendation)
focal_class.identifier: evaluate
focal_class.modifiers: @Override public
focal_class.parameters: (Recommendation<U, I> recommendation)
focal_class.return: double
focal_class.signature: double evaluate(Recommendation<U, I> recommendation)
focal_class.superclass: extends AbstractRecommendationMetric<U, I>
focal_method.body: @Override
      public double evaluate(Recommendation<U, I> recommendation) {
          UserIdealRelevanceModel<U, I> userRelModel = relModel.getModel(recommendation.getUser());
  
          int nRelItems = min(cutoff, userRelModel.getRelevantItems().size());
          if (nRelItems == 0) {
              return 0.0;
          }
  
          double ap = 0;
          int relCount = 0;
          int rank = 0;
  
          for (Tuple2od<I> pair : recommendation.getItems()) {
              rank++;
              if (userRelModel.isRelevant(pair.v1)) {
                  relCount++;
                  ap += relCount / (double) rank;
              }
              if (rank == cutoff) {
                  break;
              }
          }
  
          return ap / nRelItems;
      }
focal_method.class_method_signature: AveragePrecision.evaluate(Recommendation<U, I> recommendation)
focal_method.full_signature: @Override public double evaluate(Recommendation<U, I> recommendation)
focal_method.identifier: evaluate
focal_method.invocations: getModel getUser min size getRelevantItems getItems isRelevant
focal_method.modifiers: @Override public
focal_method.parameters: (Recommendation<U, I> recommendation)
focal_method.return: double
focal_method.signature: double evaluate(Recommendation<U, I> recommendation)