class 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();
    }

}