ConfusionMetrics { public static double getF1Score(final int tp, final int fp, final int fn) { return getFMeasure(1.0, tp, fp, fn); } private  ConfusionMetrics(); static double getPrecision(final int tp, final int fp); static double getRecall(final int tp, final int fn); static double getTrueNegativeRate(final int fp, final int tn); static double getNegativePredictiveValue(final int tn, final int fn); static double getFalseNegativeRate(final int tp, final int fn); static double getFallOut(final int fp, final int tn); static double getFalseDiscoveryRate(final int tp, final int fp); static double getFalseOmissionRate(final int tn, final int fn); static double getPrevalenceThreshold(final int tp, final int fp, final int tn, final int fn); static double getCriticalSuccessIndex(final int tp, final int fp, final int fn); static double getAccuracy(final int tp, final int fp, final int tn, final int fn); static double getErrorRate(final int tp, final int fp, final int tn, final int fn); static double getBalancedAccuracy(final int tp, final int fp, final int tn, final int fn); static double getF1Score(final int tp, final int fp, final int fn); static double getFMeasure(final double beta, final int tp, final int fp, final int fn); static double getMatthewsCorrelationCoefficient(final int tp, final int fp, final int tn, final int fn); static double getFowlkesMallowsIndex(final int tp, final int fp, final int fn); static double getInformedness(final int tp, final int fp, final int tn, final int fn); static double getMarkedness(final int tp, final int fp, final int tn, final int fn); static double getPredictedPositiveConditionRate(final int tp, final int fp, final int tn, final int fn); static double getPositiveLikelihoodRatio(final int tp, final int fp, final int tn, final int fn); static double getNegativeLikelihoodRatio(final int tp, final int fp, final int tn, final int fn); static double getDiagnosticOddsRatio(final int tp, final int fp, final int tn, final int fn);  }
@Test public void testF1Score() { for (int i = 0; i < a.length; i++) { assertEquals("F1Score not correct", f1score[i], ConfusionMetrics.getF1Score(tp(a[i], b[i]), fp(a[i], b[i]), fn(a[i], b[i])), 1E-8); } }