EvaluationUtil implements Serializable { public static TreeMap<Object, Double> extractLabelProbMap(Row row, TypeInformation labelType) { HashMap<String, Double> labelProbMap; final String detailStr = row.getField(1).toString(); try { labelProbMap = JsonConverter.fromJson(detailStr, new TypeReference<HashMap<String, Double>>() {}.getType()); } catch (Exception e) { throw new RuntimeException( String.format("Fail to deserialize detail column %s!", detailStr)); } Collection<Double> probabilities = labelProbMap.values(); probabilities.forEach(v -> Preconditions.checkArgument(v <= 1.0 && v >= 0, String.format("Probibality in %s not in range [0, 1]!", detailStr))); Preconditions.checkArgument( Math.abs(probabilities.stream().mapToDouble(Double::doubleValue).sum() - 1.0) < PROB_SUM_EPS, String.format("Probability sum in %s not equal to 1.0!", detailStr)); TreeMap<Object, Double> castLabelProbMap = new TreeMap<>(); for(Map.Entry<String, Double> entry : labelProbMap.entrySet()){ castLabelProbMap.put(castTo(entry.getKey(), labelType), entry.getValue()); } return castLabelProbMap; }  static boolean labelCompare(Object label1, Object label2, TypeInformation type); static int compare(Object o1, Object o2); static Object castTo(Object x, TypeInformation t); static BaseMetricsSummary getDetailStatistics(Iterable<Row> rows, String positiveValue, boolean binary, TypeInformation labelType); static BaseMetricsSummary getDetailStatistics(Iterable<Row> rows,
                                                         boolean binary,
                                                         Tuple2<Map<Object, Integer>, Object[]> labels,
                                                         TypeInformation labelType); static boolean checkRowFieldNotNull(Row row); static double extractLogloss(TreeMap<Object, Double> labelProbMap, Object label); static TreeMap<Object, Double> extractLabelProbMap(Row row, TypeInformation labelType); static void updateBinaryMetricsSummary(TreeMap<Object, Double> labelProbMap,
                                                  Object label,
                                                  BinaryMetricsSummary binaryMetricsSummary); static void updateMultiMetricsSummary(TreeMap<Object, Double> labelProbMap,
                                                 Object label,
                                                 Map<Object, Integer> labels,
                                                 MultiMetricsSummary multiMetricsSummary); static RegressionMetricsSummary getRegressionStatistics(Iterable<Row> rows); static MultiMetricsSummary getMultiClassMetrics(Iterable<Row> rows,
                                                           Tuple2<Map<Object, Integer>, Object[]>
                                                               labelIndexLabelArray);  }
@Test public void testException1(){ thrown.expect(RuntimeException.class); thrown.expectMessage("Fail to deserialize detail column a, b, c!"); EvaluationUtil.extractLabelProbMap(Row.of(null, "a, b, c"), Types.LONG); }