KiePMMLRegressionTableClassificationFactory { public 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) { logger.trace("getRegressionTable {}", regressionTablesMap); String className = "KiePMMLRegressionTableClassification" + classArity.addAndGet(1); CompilationUnit cloneCU = JavaParserUtils.getKiePMMLModelCompilationUnit(className, packageName, KIE_PMML_REGRESSION_TABLE_CLASSIFICATION_TEMPLATE_JAVA, KIE_PMML_REGRESSION_TABLE_CLASSIFICATION_TEMPLATE); ClassOrInterfaceDeclaration tableTemplate = cloneCU.getClassByName(className) .orElseThrow(() -> new KiePMMLException(MAIN_CLASS_NOT_FOUND + ": " + className)); final REGRESSION_NORMALIZATION_METHOD regressionNormalizationMethod = REGRESSION_NORMALIZATION_METHOD.byName(normalizationMethod.value()); final OP_TYPE opTypePmml = opType != null ? OP_TYPE.byName(opType.value()) : null; populateGetProbabilityMapMethod(normalizationMethod, tableTemplate); populateOutputFieldsMap(tableTemplate, outputFields); populateIsBinaryMethod(opType, regressionTablesMap.size(), tableTemplate); final ConstructorDeclaration constructorDeclaration = tableTemplate.getDefaultConstructor().orElseThrow(() -> new KiePMMLInternalException(String.format(MISSING_DEFAULT_CONSTRUCTOR, tableTemplate.getName()))); setConstructor(constructorDeclaration, tableTemplate.getName(), targetField, regressionNormalizationMethod, opTypePmml); addMapPopulation(constructorDeclaration.getBody(), regressionTablesMap); populateGetTargetCategory(tableTemplate, null); return new AbstractMap.SimpleEntry<>(getFullClassName(cloneCU), cloneCU.toString()); } 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; }
@Test public void getRegressionTable() { KiePMMLOutputField outputFieldCat = getOutputField("CAT-1", RESULT_FEATURE.PROBABILITY, "CatPred-1"); KiePMMLOutputField outputFieldNum = getOutputField("NUM-1", RESULT_FEATURE.PROBABILITY, "NumPred-0"); KiePMMLOutputField outputFieldPrev = getOutputField("PREV", RESULT_FEATURE.PREDICTED_VALUE, null); List<KiePMMLOutputField> outputFields = Arrays.asList(outputFieldCat, outputFieldNum, outputFieldPrev); LinkedHashMap<String, KiePMMLTableSourceCategory> toReturn = new LinkedHashMap<>(); Map.Entry<String, String> retrieved = KiePMMLRegressionTableClassificationFactory.getRegressionTable(toReturn, RegressionModel.NormalizationMethod.SOFTMAX, OpType.CATEGORICAL, outputFields, "targetField", "packageName"); assertNotNull(retrieved); }