### Question:
DiscreteEvaluator extends Evaluator { public double accuracy() { int numAtoms = tp + tn + fp + fn; if (numAtoms == 0) { return 0.0; } return (tp + tn) / (double)numAtoms; } 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 testAccuracy() { for (double threshold = 0.1; threshold <= 1.0; threshold += 0.1) { DiscreteEvaluator computer = new DiscreteEvaluator(threshold); computer.compute(trainingMap, predicate); double accuracy = computer.accuracy(); if (threshold <= 0.8) { assertEquals(0.8, accuracy, MathUtils.EPSILON); } else { assertEquals(0.2, accuracy, MathUtils.EPSILON); } } }