class ClassificationEvaluationUtil implements Serializable {

    public static Tuple2<Boolean, long[]> reduceBinaryPartitionSummary(List<BinaryPartitionSummary> values, int taskId) {
        List<BinaryPartitionSummary> list = new ArrayList<>();
        values.forEach(list::add);
        list.sort(Comparator.comparingDouble(t -> -t.maxScore));
        long curTrue = 0;
        long curFalse = 0;
        long totalTrue = 0;
        long totalFalse = 0;

        boolean firstBin = true;

        for(BinaryPartitionSummary statistics : list){
            if(statistics.taskId == taskId){
                firstBin = (totalTrue + totalFalse == 0);
                curFalse = totalFalse;
                curTrue = totalTrue;
            }
            totalTrue += statistics.curPositive;
            totalFalse += statistics.curNegative;
        }
        return Tuple2.of(firstBin, new long[]{curTrue, curFalse, totalTrue, totalFalse});
    }

}