@Test public void addCategoricalPredictors() { List<CategoricalPredictor> categoricalPredictors = IntStream.range(0, 3).mapToObj(index -> IntStream.range(0, 3).mapToObj(i -> { String predictorName = "predictorName-" + index; double coefficient = 1.23 * i; return PMMLModelTestUtils.getCategoricalPredictor(predictorName, i, coefficient); }) .collect(Collectors.toList())).reduce((categoricalPredictors1, categoricalPredictors2) -> { List<CategoricalPredictor> toReturn = new ArrayList<>(); toReturn.addAll(categoricalPredictors1); toReturn.addAll(categoricalPredictors2); return toReturn; }).get(); ClassOrInterfaceDeclaration tableTemplate = new ClassOrInterfaceDeclaration(); Map<String, MethodDeclaration> retrieved = KiePMMLRegressionTableRegressionFactory.addCategoricalPredictors(categoricalPredictors, tableTemplate); assertEquals(3, retrieved.size()); }
static Map<String, MethodDeclaration> addCategoricalPredictors(final List<CategoricalPredictor> categoricalPredictors, final ClassOrInterfaceDeclaration tableTemplate) { predictorsArity.set(0); final Map<String, List<CategoricalPredictor>> groupedCollectors = categoricalPredictors.stream() .collect(groupingBy(categoricalPredictor -> categoricalPredictor.getField().getValue())); return groupedCollectors.entrySet().stream() .map(entry -> new AbstractMap.SimpleEntry<>(entry.getKey(), addGroupedCategoricalPredictor(entry.getValue(), tableTemplate, predictorsArity.addAndGet(1)))) .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); }
KiePMMLRegressionTableRegressionFactory { static Map<String, MethodDeclaration> addCategoricalPredictors(final List<CategoricalPredictor> categoricalPredictors, final ClassOrInterfaceDeclaration tableTemplate) { predictorsArity.set(0); final Map<String, List<CategoricalPredictor>> groupedCollectors = categoricalPredictors.stream() .collect(groupingBy(categoricalPredictor -> categoricalPredictor.getField().getValue())); return groupedCollectors.entrySet().stream() .map(entry -> new AbstractMap.SimpleEntry<>(entry.getKey(), addGroupedCategoricalPredictor(entry.getValue(), tableTemplate, predictorsArity.addAndGet(1)))) .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); } }
KiePMMLRegressionTableRegressionFactory { static Map<String, MethodDeclaration> addCategoricalPredictors(final List<CategoricalPredictor> categoricalPredictors, final ClassOrInterfaceDeclaration tableTemplate) { predictorsArity.set(0); final Map<String, List<CategoricalPredictor>> groupedCollectors = categoricalPredictors.stream() .collect(groupingBy(categoricalPredictor -> categoricalPredictor.getField().getValue())); return groupedCollectors.entrySet().stream() .map(entry -> new AbstractMap.SimpleEntry<>(entry.getKey(), addGroupedCategoricalPredictor(entry.getValue(), tableTemplate, predictorsArity.addAndGet(1)))) .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); } private  KiePMMLRegressionTableRegressionFactory(); }
KiePMMLRegressionTableRegressionFactory { static Map<String, MethodDeclaration> addCategoricalPredictors(final List<CategoricalPredictor> categoricalPredictors, final ClassOrInterfaceDeclaration tableTemplate) { predictorsArity.set(0); final Map<String, List<CategoricalPredictor>> groupedCollectors = categoricalPredictors.stream() .collect(groupingBy(categoricalPredictor -> categoricalPredictor.getField().getValue())); return groupedCollectors.entrySet().stream() .map(entry -> new AbstractMap.SimpleEntry<>(entry.getKey(), addGroupedCategoricalPredictor(entry.getValue(), tableTemplate, predictorsArity.addAndGet(1)))) .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); } private  KiePMMLRegressionTableRegressionFactory(); static LinkedHashMap<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables,
                                                                                        final RegressionModel.NormalizationMethod normalizationMethod,
                                                                                        final List<KiePMMLOutputField> outputFields,
                                                                                        final String targetField,
                                                                                        final String packageName); static Map.Entry<String, String> getRegressionTable(final RegressionTable regressionTable,
                                                               final RegressionModel.NormalizationMethod normalizationMethod,
                                                               final List<KiePMMLOutputField> outputFields,
                                                               final String targetField,
                                                               final String packageName); }
KiePMMLRegressionTableRegressionFactory { static Map<String, MethodDeclaration> addCategoricalPredictors(final List<CategoricalPredictor> categoricalPredictors, final ClassOrInterfaceDeclaration tableTemplate) { predictorsArity.set(0); final Map<String, List<CategoricalPredictor>> groupedCollectors = categoricalPredictors.stream() .collect(groupingBy(categoricalPredictor -> categoricalPredictor.getField().getValue())); return groupedCollectors.entrySet().stream() .map(entry -> new AbstractMap.SimpleEntry<>(entry.getKey(), addGroupedCategoricalPredictor(entry.getValue(), tableTemplate, predictorsArity.addAndGet(1)))) .collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue)); } private  KiePMMLRegressionTableRegressionFactory(); static LinkedHashMap<String, KiePMMLTableSourceCategory> getRegressionTables(final List<RegressionTable> regressionTables,
                                                                                        final RegressionModel.NormalizationMethod normalizationMethod,
                                                                                        final List<KiePMMLOutputField> outputFields,
                                                                                        final String targetField,
                                                                                        final String packageName); static Map.Entry<String, String> getRegressionTable(final RegressionTable regressionTable,
                                                               final RegressionModel.NormalizationMethod normalizationMethod,
                                                               final List<KiePMMLOutputField> outputFields,
                                                               final String targetField,
                                                               final String packageName); static final String KIE_PMML_REGRESSION_TABLE_REGRESSION_TEMPLATE_JAVA; static final String KIE_PMML_REGRESSION_TABLE_REGRESSION_TEMPLATE; }