use of org.kie.pmml.commons.Constants.VARIABLE_NAME_TEMPLATE in project drools by kiegroup.
the class KiePMMLRegressionTableFactory method getCategoricalPredictorsExpressions.
/**
* Create the <b>CategoricalPredictor</b>s lambda <code>Expression</code>s map
* @param categoricalPredictors
* @param body
* @return
*/
static Map<String, Expression> getCategoricalPredictorsExpressions(final List<CategoricalPredictor> categoricalPredictors, final BlockStmt body, final String variableName) {
final Map<String, List<CategoricalPredictor>> groupedCollectors = categoricalPredictors.stream().collect(groupingBy(categoricalPredictor -> categoricalPredictor.getField().getValue()));
final String categoricalPredictorMapNameBase = getSanitizedVariableName(String.format("%sMap", variableName));
final AtomicInteger counter = new AtomicInteger();
return groupedCollectors.entrySet().stream().map(entry -> {
final String categoricalPredictorMapName = String.format(VARIABLE_NAME_TEMPLATE, categoricalPredictorMapNameBase, counter.getAndIncrement());
populateWithGroupedCategoricalPredictorMap(entry.getValue(), body, categoricalPredictorMapName);
return new AbstractMap.SimpleEntry<>(entry.getKey(), getCategoricalPredictorExpression(categoricalPredictorMapName));
}).collect(Collectors.toMap(AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue));
}
Aggregations