@Test public void testEmptyInput() throws Exception{ Row[] rows = new Row[]{ Row.of(null, null), Row.of("1", null), Row.of(null, "1") }; MemSourceBatchOp data = new MemSourceBatchOp(Arrays.asList(rows), new TableSchema(new String[]{"pred", "label"}, new TypeInformation[]{Types.STRING, Types.STRING})); thrown.expect(Exception.class); EvalBinaryClassBatchOp op = new EvalBinaryClassBatchOp() .setLabelCol("label") .setPredictionDetailCol("pred") .linkFrom(data); op.print(); }
@Override public EvalBinaryClassBatchOp linkFrom(BatchOperator<?>... inputs){ BatchOperator<?> in = checkAndGetFirst(inputs); String labelColName = this.get(EvalMultiClassParams.LABEL_COL); TypeInformation labelType = TableUtil.findColTypeWithAssertAndHint(in.getSchema(), labelColName); String positiveValue = this.get(EvalBinaryClassParams.POS_LABEL_VAL_STR); Preconditions.checkArgument(getParams().contains(EvalBinaryClassParams.PREDICTION_DETAIL_COL), "Binary Evaluation must give predictionDetailCol!"); String predDetailColName = this.get(EvalMultiClassParams.PREDICTION_DETAIL_COL); TableUtil.assertSelectedColExist(in.getColNames(), labelColName, predDetailColName); DataSet<Row> data = in.select(new String[] {labelColName, predDetailColName}).getDataSet(); DataSet<BaseMetricsSummary> res = calLabelPredDetailLocal(data, positiveValue, labelType); DataSet<BaseMetricsSummary> metrics = res .reduce(new EvaluationUtil.ReduceBaseMetrics()); this.setOutput(metrics.flatMap(new EvaluationUtil.SaveDataAsParams()), new String[] {"Data"}, new TypeInformation[] {Types.STRING}); return this; }
EvalBinaryClassBatchOp extends BatchOperator<EvalBinaryClassBatchOp> implements
	EvalBinaryClassParams<EvalBinaryClassBatchOp>, EvaluationMetricsCollector<BinaryClassMetrics, EvalBinaryClassBatchOp> { @Override public EvalBinaryClassBatchOp linkFrom(BatchOperator<?>... inputs){ BatchOperator<?> in = checkAndGetFirst(inputs); String labelColName = this.get(EvalMultiClassParams.LABEL_COL); TypeInformation labelType = TableUtil.findColTypeWithAssertAndHint(in.getSchema(), labelColName); String positiveValue = this.get(EvalBinaryClassParams.POS_LABEL_VAL_STR); Preconditions.checkArgument(getParams().contains(EvalBinaryClassParams.PREDICTION_DETAIL_COL), "Binary Evaluation must give predictionDetailCol!"); String predDetailColName = this.get(EvalMultiClassParams.PREDICTION_DETAIL_COL); TableUtil.assertSelectedColExist(in.getColNames(), labelColName, predDetailColName); DataSet<Row> data = in.select(new String[] {labelColName, predDetailColName}).getDataSet(); DataSet<BaseMetricsSummary> res = calLabelPredDetailLocal(data, positiveValue, labelType); DataSet<BaseMetricsSummary> metrics = res .reduce(new EvaluationUtil.ReduceBaseMetrics()); this.setOutput(metrics.flatMap(new EvaluationUtil.SaveDataAsParams()), new String[] {"Data"}, new TypeInformation[] {Types.STRING}); return this; } }
EvalBinaryClassBatchOp extends BatchOperator<EvalBinaryClassBatchOp> implements
	EvalBinaryClassParams<EvalBinaryClassBatchOp>, EvaluationMetricsCollector<BinaryClassMetrics, EvalBinaryClassBatchOp> { @Override public EvalBinaryClassBatchOp linkFrom(BatchOperator<?>... inputs){ BatchOperator<?> in = checkAndGetFirst(inputs); String labelColName = this.get(EvalMultiClassParams.LABEL_COL); TypeInformation labelType = TableUtil.findColTypeWithAssertAndHint(in.getSchema(), labelColName); String positiveValue = this.get(EvalBinaryClassParams.POS_LABEL_VAL_STR); Preconditions.checkArgument(getParams().contains(EvalBinaryClassParams.PREDICTION_DETAIL_COL), "Binary Evaluation must give predictionDetailCol!"); String predDetailColName = this.get(EvalMultiClassParams.PREDICTION_DETAIL_COL); TableUtil.assertSelectedColExist(in.getColNames(), labelColName, predDetailColName); DataSet<Row> data = in.select(new String[] {labelColName, predDetailColName}).getDataSet(); DataSet<BaseMetricsSummary> res = calLabelPredDetailLocal(data, positiveValue, labelType); DataSet<BaseMetricsSummary> metrics = res .reduce(new EvaluationUtil.ReduceBaseMetrics()); this.setOutput(metrics.flatMap(new EvaluationUtil.SaveDataAsParams()), new String[] {"Data"}, new TypeInformation[] {Types.STRING}); return this; } EvalBinaryClassBatchOp();  EvalBinaryClassBatchOp(Params params); }
EvalBinaryClassBatchOp extends BatchOperator<EvalBinaryClassBatchOp> implements
	EvalBinaryClassParams<EvalBinaryClassBatchOp>, EvaluationMetricsCollector<BinaryClassMetrics, EvalBinaryClassBatchOp> { @Override public EvalBinaryClassBatchOp linkFrom(BatchOperator<?>... inputs){ BatchOperator<?> in = checkAndGetFirst(inputs); String labelColName = this.get(EvalMultiClassParams.LABEL_COL); TypeInformation labelType = TableUtil.findColTypeWithAssertAndHint(in.getSchema(), labelColName); String positiveValue = this.get(EvalBinaryClassParams.POS_LABEL_VAL_STR); Preconditions.checkArgument(getParams().contains(EvalBinaryClassParams.PREDICTION_DETAIL_COL), "Binary Evaluation must give predictionDetailCol!"); String predDetailColName = this.get(EvalMultiClassParams.PREDICTION_DETAIL_COL); TableUtil.assertSelectedColExist(in.getColNames(), labelColName, predDetailColName); DataSet<Row> data = in.select(new String[] {labelColName, predDetailColName}).getDataSet(); DataSet<BaseMetricsSummary> res = calLabelPredDetailLocal(data, positiveValue, labelType); DataSet<BaseMetricsSummary> metrics = res .reduce(new EvaluationUtil.ReduceBaseMetrics()); this.setOutput(metrics.flatMap(new EvaluationUtil.SaveDataAsParams()), new String[] {"Data"}, new TypeInformation[] {Types.STRING}); return this; } EvalBinaryClassBatchOp();  EvalBinaryClassBatchOp(Params params); @Override BinaryClassMetrics createMetrics(List<Row> rows); @Override EvalBinaryClassBatchOp linkFrom(BatchOperator<?>... inputs); }
EvalBinaryClassBatchOp extends BatchOperator<EvalBinaryClassBatchOp> implements
	EvalBinaryClassParams<EvalBinaryClassBatchOp>, EvaluationMetricsCollector<BinaryClassMetrics, EvalBinaryClassBatchOp> { @Override public EvalBinaryClassBatchOp linkFrom(BatchOperator<?>... inputs){ BatchOperator<?> in = checkAndGetFirst(inputs); String labelColName = this.get(EvalMultiClassParams.LABEL_COL); TypeInformation labelType = TableUtil.findColTypeWithAssertAndHint(in.getSchema(), labelColName); String positiveValue = this.get(EvalBinaryClassParams.POS_LABEL_VAL_STR); Preconditions.checkArgument(getParams().contains(EvalBinaryClassParams.PREDICTION_DETAIL_COL), "Binary Evaluation must give predictionDetailCol!"); String predDetailColName = this.get(EvalMultiClassParams.PREDICTION_DETAIL_COL); TableUtil.assertSelectedColExist(in.getColNames(), labelColName, predDetailColName); DataSet<Row> data = in.select(new String[] {labelColName, predDetailColName}).getDataSet(); DataSet<BaseMetricsSummary> res = calLabelPredDetailLocal(data, positiveValue, labelType); DataSet<BaseMetricsSummary> metrics = res .reduce(new EvaluationUtil.ReduceBaseMetrics()); this.setOutput(metrics.flatMap(new EvaluationUtil.SaveDataAsParams()), new String[] {"Data"}, new TypeInformation[] {Types.STRING}); return this; } EvalBinaryClassBatchOp();  EvalBinaryClassBatchOp(Params params); @Override BinaryClassMetrics createMetrics(List<Row> rows); @Override EvalBinaryClassBatchOp linkFrom(BatchOperator<?>... inputs);  }