### Question:
PrecisionFixedRecall extends EvaluationMeasure { public double computeResult(boolean[] classes, double[] scores) { MatrixUtils.mergeSort(scores, classes); int totalPos = countPositives(classes); int cumPosCounts = 0; for ( int i = 1; i <= classes.length; i++ ){ if ( classes[classes.length-i] ){ cumPosCounts += 1; } double recall = (double) cumPosCounts / totalPos; if ( recall >= recallRate ){ return (double) cumPosCounts/i; } } return 0; } PrecisionFixedRecall(String name, double recall); double computeResult(boolean[] classes, double[] scores);  }### Answer:
@Test public void test1(){ boolean [] classes = {true, true, false, false, false, false, false}; double [] scores = {9, 8, 7, 1, 5, 10, 3}; double[] measureResults = new double[10]; double[] correctResults = {0.5, 0.5, 0.5, 0.5, 0.5, 0.6667, 0.6667, 0.6667, 0.6667, 0.6667}; PrecisionFixedRecall measure; for ( int i = 1; i <= 10; i++ ){ measure = new PrecisionFixedRecall("PR", i*10); double result = measure.computeResult(classes, scores); measureResults[i-1] = result; } for ( int i = 0; i < 10; i++ ){ assertEquals(measureResults[i], correctResults[i], 0.0001); } }
@Test public void test2(){ boolean [] classes = {false, true, false, true, false, true, true, true, false, false}; double [] scores = {1, 10, 9, 8, 7, 6, 5, 4, 3, 2 }; double[] measureResults = new double[10]; double[] correctResults = {1, 1, 0.6667, 0.6667, 0.6, 0.6, 0.6667, 0.6667, 0.7143, 0.7143}; PrecisionFixedRecall measure; for ( int i = 1; i <= 10; i++ ){ measure = new PrecisionFixedRecall("PR", i*10); double result = measure.computeResult(classes, scores); measureResults[i-1] = result; } for ( int i = 0; i < 10; i++ ){ assertEquals(measureResults[i], correctResults[i], 0.0001); } }
@Test public void test3(){ boolean [] classes = {false, true, false, true, true, true, false, true, false, false}; double [] scores = {1, 10, 9, 8, 7, 6, 5, 4, 3, 2}; double[] measureResults = new double[10]; double[] correctResults = {1, 1, 0.6667, 0.6667, 0.75, 0.75, 0.8, 0.8, 0.7143, 0.7143}; PrecisionFixedRecall measure; for ( int i = 1; i <= 10; i++ ){ measure = new PrecisionFixedRecall("PR", i*10); double result = measure.computeResult(classes, scores); measureResults[i-1] = result; } for ( int i = 0; i < 10; i++ ){ assertEquals(measureResults[i], correctResults[i], 0.0001); } }