@Test public void populateOutputFieldsMap() { final List<KiePMMLOutputField> outputFields = new ArrayList<>(); KiePMMLOutputField predictedOutputField = getOutputField("KOF-TARGET", RESULT_FEATURE.PREDICTED_VALUE, "TARGET"); outputFields.add(predictedOutputField); final List<KiePMMLOutputField> probabilityOutputFields = IntStream.range(0, 2) .mapToObj(index -> getOutputField("KOF-PROB-" + index, RESULT_FEATURE.PROBABILITY, "PROB-" + index)) .collect(Collectors.toList()); outputFields.addAll(probabilityOutputFields); KiePMMLRegressionTableClassificationFactory.populateOutputFieldsMap(modelTemplate, outputFields); MethodDeclaration methodDeclaration = modelTemplate.getMethodsByName("populateOutputFieldsMapWithResult").get(0); BlockStmt body = methodDeclaration.getBody().get(); NodeList<Statement> retrieved = body.getStatements(); assertEquals(1, retrieved.size()); methodDeclaration = modelTemplate.getMethodsByName("populateOutputFieldsMapWithProbability").get(0); body = methodDeclaration.getBody().get(); retrieved = body.getStatements(); assertEquals(probabilityOutputFields.size(), retrieved.size()); }
static void populateOutputFieldsMap(final ClassOrInterfaceDeclaration tableTemplate, final List<KiePMMLOutputField> outputFields) { MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("populateOutputFieldsMapWithResult").get(0); BlockStmt body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, "populateOutputFieldsMapWithResult"))); populateOutputFieldsMapWithResult(body, outputFields); methodDeclaration = tableTemplate.getMethodsByName("populateOutputFieldsMapWithProbability").get(0); body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, "populateOutputFieldsMapWithProbability"))); populateOutputFieldsMapWithProbability(body, outputFields); }
KiePMMLRegressionTableClassificationFactory { static void populateOutputFieldsMap(final ClassOrInterfaceDeclaration tableTemplate, final List<KiePMMLOutputField> outputFields) { MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("populateOutputFieldsMapWithResult").get(0); BlockStmt body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, "populateOutputFieldsMapWithResult"))); populateOutputFieldsMapWithResult(body, outputFields); methodDeclaration = tableTemplate.getMethodsByName("populateOutputFieldsMapWithProbability").get(0); body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, "populateOutputFieldsMapWithProbability"))); populateOutputFieldsMapWithProbability(body, outputFields); } }
KiePMMLRegressionTableClassificationFactory { static void populateOutputFieldsMap(final ClassOrInterfaceDeclaration tableTemplate, final List<KiePMMLOutputField> outputFields) { MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("populateOutputFieldsMapWithResult").get(0); BlockStmt body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, "populateOutputFieldsMapWithResult"))); populateOutputFieldsMapWithResult(body, outputFields); methodDeclaration = tableTemplate.getMethodsByName("populateOutputFieldsMapWithProbability").get(0); body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, "populateOutputFieldsMapWithProbability"))); populateOutputFieldsMapWithProbability(body, outputFields); } private  KiePMMLRegressionTableClassificationFactory(); }
KiePMMLRegressionTableClassificationFactory { static void populateOutputFieldsMap(final ClassOrInterfaceDeclaration tableTemplate, final List<KiePMMLOutputField> outputFields) { MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("populateOutputFieldsMapWithResult").get(0); BlockStmt body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, "populateOutputFieldsMapWithResult"))); populateOutputFieldsMapWithResult(body, outputFields); methodDeclaration = tableTemplate.getMethodsByName("populateOutputFieldsMapWithProbability").get(0); body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, "populateOutputFieldsMapWithProbability"))); populateOutputFieldsMapWithProbability(body, outputFields); } private  KiePMMLRegressionTableClassificationFactory(); static Map<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables, final RegressionModel.NormalizationMethod normalizationMethod, final OpType opType, final List<KiePMMLOutputField> outputFields, final String targetField, final String packageName); static Map.Entry<String, String> getRegressionTable(final LinkedHashMap<String, KiePMMLTableSourceCategory> regressionTablesMap, final RegressionModel.NormalizationMethod normalizationMethod, final OpType opType, final List<KiePMMLOutputField> outputFields, final String targetField, final String packageName); }
KiePMMLRegressionTableClassificationFactory { static void populateOutputFieldsMap(final ClassOrInterfaceDeclaration tableTemplate, final List<KiePMMLOutputField> outputFields) { MethodDeclaration methodDeclaration = tableTemplate.getMethodsByName("populateOutputFieldsMapWithResult").get(0); BlockStmt body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, "populateOutputFieldsMapWithResult"))); populateOutputFieldsMapWithResult(body, outputFields); methodDeclaration = tableTemplate.getMethodsByName("populateOutputFieldsMapWithProbability").get(0); body = methodDeclaration.getBody().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_BODY_TEMPLATE, "populateOutputFieldsMapWithProbability"))); populateOutputFieldsMapWithProbability(body, outputFields); } private  KiePMMLRegressionTableClassificationFactory(); static Map<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables, final RegressionModel.NormalizationMethod normalizationMethod, final OpType opType, final List<KiePMMLOutputField> outputFields, final String targetField, final String packageName); static Map.Entry<String, String> getRegressionTable(final LinkedHashMap<String, KiePMMLTableSourceCategory> regressionTablesMap, final RegressionModel.NormalizationMethod normalizationMethod, final OpType opType, final List<KiePMMLOutputField> outputFields, final String targetField, final String packageName); static final String KIE_PMML_REGRESSION_TABLE_CLASSIFICATION_TEMPLATE_JAVA; static final String KIE_PMML_REGRESSION_TABLE_CLASSIFICATION_TEMPLATE; }