@Test public void getRegressionTablesMap() throws IOException { String targetFieldName = "targetFieldName"; Map<String, KiePMMLTableSourceCategory> retrieved = KiePMMLRegressionModelFactory .getRegressionTablesMap(dataDictionary, regressionModel, targetFieldName, Collections.emptyList(), PACKAGE_NAME); int expectedSize = regressionTables.size() + 1; assertEquals(expectedSize, retrieved.size()); final Collection<KiePMMLTableSourceCategory> values = retrieved.values(); regressionTables.forEach(regressionTable -> assertTrue(values.stream().anyMatch(kiePMMLTableSourceCategory -> kiePMMLTableSourceCategory.getCategory().equals(regressionTable.getTargetCategory())))); }
static Map<String, KiePMMLTableSourceCategory> getRegressionTablesMap(final DataDictionary dataDictionary, final RegressionModel model, final String targetFieldName, final List<KiePMMLOutputField> outputFields, final String packageName) { final DataField targetDataField = dataDictionary.getDataFields().stream() .filter(field -> Objects.equals(targetFieldName, field.getName().getValue())) .findFirst().orElse(null); final OpType opType = targetDataField != null ? targetDataField.getOpType() : null; Map<String, KiePMMLTableSourceCategory> toReturn; if (isRegression(model.getMiningFunction(), targetFieldName, opType)) { toReturn = KiePMMLRegressionTableRegressionFactory.getRegressionTables(Collections.singletonList(model.getRegressionTables().get(0)), model.getNormalizationMethod(), outputFields, targetFieldName, packageName); } else { toReturn = KiePMMLRegressionTableClassificationFactory.getRegressionTables(model.getRegressionTables(), model.getNormalizationMethod(), opType, outputFields, targetFieldName, packageName); } return toReturn; }
KiePMMLRegressionModelFactory { static Map<String, KiePMMLTableSourceCategory> getRegressionTablesMap(final DataDictionary dataDictionary, final RegressionModel model, final String targetFieldName, final List<KiePMMLOutputField> outputFields, final String packageName) { final DataField targetDataField = dataDictionary.getDataFields().stream() .filter(field -> Objects.equals(targetFieldName, field.getName().getValue())) .findFirst().orElse(null); final OpType opType = targetDataField != null ? targetDataField.getOpType() : null; Map<String, KiePMMLTableSourceCategory> toReturn; if (isRegression(model.getMiningFunction(), targetFieldName, opType)) { toReturn = KiePMMLRegressionTableRegressionFactory.getRegressionTables(Collections.singletonList(model.getRegressionTables().get(0)), model.getNormalizationMethod(), outputFields, targetFieldName, packageName); } else { toReturn = KiePMMLRegressionTableClassificationFactory.getRegressionTables(model.getRegressionTables(), model.getNormalizationMethod(), opType, outputFields, targetFieldName, packageName); } return toReturn; } }
KiePMMLRegressionModelFactory { static Map<String, KiePMMLTableSourceCategory> getRegressionTablesMap(final DataDictionary dataDictionary, final RegressionModel model, final String targetFieldName, final List<KiePMMLOutputField> outputFields, final String packageName) { final DataField targetDataField = dataDictionary.getDataFields().stream() .filter(field -> Objects.equals(targetFieldName, field.getName().getValue())) .findFirst().orElse(null); final OpType opType = targetDataField != null ? targetDataField.getOpType() : null; Map<String, KiePMMLTableSourceCategory> toReturn; if (isRegression(model.getMiningFunction(), targetFieldName, opType)) { toReturn = KiePMMLRegressionTableRegressionFactory.getRegressionTables(Collections.singletonList(model.getRegressionTables().get(0)), model.getNormalizationMethod(), outputFields, targetFieldName, packageName); } else { toReturn = KiePMMLRegressionTableClassificationFactory.getRegressionTables(model.getRegressionTables(), model.getNormalizationMethod(), opType, outputFields, targetFieldName, packageName); } return toReturn; } private  KiePMMLRegressionModelFactory(); }
KiePMMLRegressionModelFactory { static Map<String, KiePMMLTableSourceCategory> getRegressionTablesMap(final DataDictionary dataDictionary, final RegressionModel model, final String targetFieldName, final List<KiePMMLOutputField> outputFields, final String packageName) { final DataField targetDataField = dataDictionary.getDataFields().stream() .filter(field -> Objects.equals(targetFieldName, field.getName().getValue())) .findFirst().orElse(null); final OpType opType = targetDataField != null ? targetDataField.getOpType() : null; Map<String, KiePMMLTableSourceCategory> toReturn; if (isRegression(model.getMiningFunction(), targetFieldName, opType)) { toReturn = KiePMMLRegressionTableRegressionFactory.getRegressionTables(Collections.singletonList(model.getRegressionTables().get(0)), model.getNormalizationMethod(), outputFields, targetFieldName, packageName); } else { toReturn = KiePMMLRegressionTableClassificationFactory.getRegressionTables(model.getRegressionTables(), model.getNormalizationMethod(), opType, outputFields, targetFieldName, packageName); } return toReturn; } private  KiePMMLRegressionModelFactory(); static KiePMMLRegressionModel getKiePMMLRegressionModelClasses(final DataDictionary dataDictionary,
                                                                          final TransformationDictionary transformationDictionary,
                                                                          final RegressionModel model); static Map<String, String> getKiePMMLRegressionModelSourcesMap(final DataDictionary dataDictionary,
                                                                          final TransformationDictionary transformationDictionary,
                                                                          final RegressionModel model,
                                                                          final String packageName); }
KiePMMLRegressionModelFactory { static Map<String, KiePMMLTableSourceCategory> getRegressionTablesMap(final DataDictionary dataDictionary, final RegressionModel model, final String targetFieldName, final List<KiePMMLOutputField> outputFields, final String packageName) { final DataField targetDataField = dataDictionary.getDataFields().stream() .filter(field -> Objects.equals(targetFieldName, field.getName().getValue())) .findFirst().orElse(null); final OpType opType = targetDataField != null ? targetDataField.getOpType() : null; Map<String, KiePMMLTableSourceCategory> toReturn; if (isRegression(model.getMiningFunction(), targetFieldName, opType)) { toReturn = KiePMMLRegressionTableRegressionFactory.getRegressionTables(Collections.singletonList(model.getRegressionTables().get(0)), model.getNormalizationMethod(), outputFields, targetFieldName, packageName); } else { toReturn = KiePMMLRegressionTableClassificationFactory.getRegressionTables(model.getRegressionTables(), model.getNormalizationMethod(), opType, outputFields, targetFieldName, packageName); } return toReturn; } private  KiePMMLRegressionModelFactory(); static KiePMMLRegressionModel getKiePMMLRegressionModelClasses(final DataDictionary dataDictionary,
                                                                          final TransformationDictionary transformationDictionary,
                                                                          final RegressionModel model); static Map<String, String> getKiePMMLRegressionModelSourcesMap(final DataDictionary dataDictionary,
                                                                          final TransformationDictionary transformationDictionary,
                                                                          final RegressionModel model,
                                                                          final String packageName);  }