@Test public void testApply() { assertEquals(1.0, aggregator.apply(new double[]{1.0, 1.0, 1.0, 0.0}), 0.001); }
@Override public Double apply(double[] estimations) { A.notEmpty(estimations, "estimations vector"); Map<Double, Integer> cntrsByCls = new HashMap<>(); for (Double predictedValue : estimations) { Integer cntrVal = cntrsByCls.getOrDefault(predictedValue, 0) + 1; cntrsByCls.put(predictedValue, cntrVal); } return cntrsByCls.entrySet().stream() .max(Comparator.comparing(Map.Entry::getValue)) .get().getKey(); }
OnMajorityPredictionsAggregator implements PredictionsAggregator { @Override public Double apply(double[] estimations) { A.notEmpty(estimations, "estimations vector"); Map<Double, Integer> cntrsByCls = new HashMap<>(); for (Double predictedValue : estimations) { Integer cntrVal = cntrsByCls.getOrDefault(predictedValue, 0) + 1; cntrsByCls.put(predictedValue, cntrVal); } return cntrsByCls.entrySet().stream() .max(Comparator.comparing(Map.Entry::getValue)) .get().getKey(); } }
OnMajorityPredictionsAggregator implements PredictionsAggregator { @Override public Double apply(double[] estimations) { A.notEmpty(estimations, "estimations vector"); Map<Double, Integer> cntrsByCls = new HashMap<>(); for (Double predictedValue : estimations) { Integer cntrVal = cntrsByCls.getOrDefault(predictedValue, 0) + 1; cntrsByCls.put(predictedValue, cntrVal); } return cntrsByCls.entrySet().stream() .max(Comparator.comparing(Map.Entry::getValue)) .get().getKey(); }  }
OnMajorityPredictionsAggregator implements PredictionsAggregator { @Override public Double apply(double[] estimations) { A.notEmpty(estimations, "estimations vector"); Map<Double, Integer> cntrsByCls = new HashMap<>(); for (Double predictedValue : estimations) { Integer cntrVal = cntrsByCls.getOrDefault(predictedValue, 0) + 1; cntrsByCls.put(predictedValue, cntrVal); } return cntrsByCls.entrySet().stream() .max(Comparator.comparing(Map.Entry::getValue)) .get().getKey(); }  @Override Double apply(double[] estimations); }
OnMajorityPredictionsAggregator implements PredictionsAggregator { @Override public Double apply(double[] estimations) { A.notEmpty(estimations, "estimations vector"); Map<Double, Integer> cntrsByCls = new HashMap<>(); for (Double predictedValue : estimations) { Integer cntrVal = cntrsByCls.getOrDefault(predictedValue, 0) + 1; cntrsByCls.put(predictedValue, cntrVal); } return cntrsByCls.entrySet().stream() .max(Comparator.comparing(Map.Entry::getValue)) .get().getKey(); }  @Override Double apply(double[] estimations);  }