### Question:
DiscreteEvaluator extends Evaluator { public double f1() { return fScore(1.0); } DiscreteEvaluator();  DiscreteEvaluator(double threshold);  DiscreteEvaluator(double threshold, String representative);  DiscreteEvaluator(double threshold, RepresentativeMetric representative); @Override void compute(TrainingMap trainingMap); @Override void compute(TrainingMap trainingMap, StandardPredicate predicate); @Override double getRepresentativeMetric(); @Override boolean isHigherRepresentativeBetter(); double getThreshold(); double positivePrecision(); double negativePrecision(); double positiveRecall(); double negativeRecall(); double f1(); double fScore(double beta); double accuracy(); @Override String getAllStats(); static final String CONFIG_PREFIX; static final String THRESHOLD_KEY; static final double DEFAULT_THRESHOLD; static final String REPRESENTATIVE_KEY; static final String DEFAULT_REPRESENTATIVE; }### Answer:
@Test public void testF1() { for (double threshold = 0.1; threshold <= 1.0; threshold += 0.1) { DiscreteEvaluator computer = new DiscreteEvaluator(threshold); computer.compute(trainingMap, predicate); double f1 = computer.f1(); if (threshold <= 0.8) { assertEquals(2.0 * 0.8 / 1.8, f1, MathUtils.EPSILON); } else { assertEquals(0.0, f1, MathUtils.EPSILON); } } }