class ClassificationEvaluationUtil implements Serializable {

    public static Tuple2<Map<Object, Integer>, Object[]> buildLabelIndexLabelArray(HashSet<Object> set,
                                                                                   boolean binary,
                                                                                   String positiveValue,
                                                                                   TypeInformation labelType) {
        Object[] labels = set.toArray();
        Arrays.sort(labels, Collections.reverseOrder());

        Preconditions.checkArgument(labels.length >= 2, "The distinct label number less than 2!");
        Preconditions.checkArgument(!binary || labels.length == BINARY_LABEL_NUMBER,
            "The number of labels must be equal to 2!");
        Map<Object, Integer> map = new HashMap<>(labels.length);
        if (binary && null != positiveValue) {
            if (EvaluationUtil.labelCompare(labels[1], positiveValue, labelType)) {
                Object tmp = labels[1];
                labels[1] = labels[0];
                labels[0] = tmp;
            } else if (!EvaluationUtil.labelCompare(labels[0], positiveValue, labelType)) {
                throw new IllegalArgumentException("Not contain positiveValue");
            }
            map.put(labels[0], 0);
            map.put(labels[1], 1);
        } else {
            for (int i = 0; i < labels.length; i++) {
                map.put(labels[i], i);
            }
        }
        return Tuple2.of(map, labels);
    }

}