test_class.file: modules/ml/src/test/java/org/apache/ignite/ml/selection/scoring/metric/classification/FmeasureTest.java
test_class.identifier: FmeasureTest
test_case.body: @Test
      public void testScore() {
          Fmeasure<Integer> scoreCalculator = new Fmeasure<>(1);
  
          LabelPairCursor<Integer> cursor = new TestLabelPairCursor<>(
              Arrays.asList(1, 0, 1, 0, 1, 0),
              Arrays.asList(1, 0, 0, 1, 1, 0)
          );
  
          double score = scoreCalculator.score(cursor.iterator());
  
          assertEquals((double)2 / 3, score, 1e-12);
      }
test_case.class_method_signature: FmeasureTest.testScore()
test_case.full_signature: @Test public void testScore()
test_case.identifier: testScore
test_case.invocations: asList asList score iterator assertEquals
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testScore()
focal_class.file: modules/ml/src/main/java/org/apache/ignite/ml/selection/scoring/metric/classification/Fmeasure.java
focal_class.identifier: Fmeasure
focal_class.class_method_signature: Fmeasure.Fmeasure(L clsLb)
focal_class.full_signature: public  Fmeasure(L clsLb)
focal_class.identifier: Fmeasure
focal_class.modifiers: public
focal_class.parameters: (L clsLb)
focal_class.signature:  Fmeasure(L clsLb)
focal_class.class_method_signature: Fmeasure.score(Iterator<LabelPair<L>> it)
focal_class.full_signature: @Override public double score(Iterator<LabelPair<L>> it)
focal_class.identifier: score
focal_class.modifiers: @Override public
focal_class.parameters: (Iterator<LabelPair<L>> it)
focal_class.return: double
focal_class.signature: double score(Iterator<LabelPair<L>> it)
focal_class.class_method_signature: Fmeasure.name()
focal_class.full_signature: @Override public String name()
focal_class.identifier: name
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String name()
focal_class.superclass: extends ClassMetric<L>
focal_method.body: @Override public double score(Iterator<LabelPair<L>> it) {
          if (clsLb != null) {
              long tp = 0;
              long fn = 0;
              long fp = 0;
              double recall;
              double precision;
  
              while (it.hasNext()) {
                  LabelPair<L> e = it.next();
  
                  L prediction = e.getPrediction();
                  L truth = e.getTruth();
  
                  if (clsLb.equals(truth)) {
                      if (prediction.equals(truth))
                          tp++;
                      else
                          fn++;
                  }
  
                  if (clsLb.equals(prediction) && !prediction.equals(truth))
                      fp++;
              }
              long denominatorRecall = tp + fn;
  
              long denominatorPrecision = tp + fp;
  
              // according to https://github.com/dice-group/gerbil/wiki/Precision,-Recall-and-F1-measure
              recall = denominatorRecall == 0 ? 1 : (double)tp / denominatorRecall;
              precision = denominatorPrecision == 0 ? 1 : (double)tp / denominatorPrecision;
  
              return 2 * (recall * precision) / (recall + precision);
          }
          else
              return Double.NaN;
      }
focal_method.class_method_signature: Fmeasure.score(Iterator<LabelPair<L>> it)
focal_method.full_signature: @Override public double score(Iterator<LabelPair<L>> it)
focal_method.identifier: score
focal_method.invocations: hasNext next getPrediction getTruth equals equals equals equals
focal_method.modifiers: @Override public
focal_method.parameters: (Iterator<LabelPair<L>> it)
focal_method.return: double
focal_method.signature: double score(Iterator<LabelPair<L>> it)