class EvaluationUtil implements Serializable {

    public static MultiMetricsSummary getMultiClassMetrics(Iterable<Row> rows,
                                                           Tuple2<Map<Object, Integer>, Object[]>
                                                               labelIndexLabelArray) {
        final Object[] recordLabel = labelIndexLabelArray.f1;
        final Map<Object, Integer> labelIndexMap = labelIndexLabelArray.f0;
        final int n = recordLabel.length;
        MultiMetricsSummary multiMetricsSummary = new MultiMetricsSummary(new long[n][n], recordLabel, -1, 0L);
        for (Row r : rows) {
            if (checkRowFieldNotNull(r)) {
                multiMetricsSummary.total++;
                int label = labelIndexMap.get(r.getField(0));
                int prediction = labelIndexMap.get(r.getField(1));
                multiMetricsSummary.matrix.setValue(prediction, label,
                    multiMetricsSummary.matrix.getValue(prediction, label) + 1);
            }
        }
        return multiMetricsSummary.total == 0 ? null : multiMetricsSummary;
    }

}