KiePMMLRegressionTable { public Object evaluateRegression(Map<String, Object> input) { final AtomicReference<Double> result = new AtomicReference<>(intercept); final Map<String, Double> resultMap = new HashMap<>(); for (Map.Entry<String, Function<Double, Double>> entry : numericFunctionMap.entrySet()) { String key = entry.getKey(); if (input.containsKey(key)) { resultMap.put(key, entry.getValue().apply(((Number) input.get(key)).doubleValue())); } } for (Map.Entry<String, Function<Object, Double>> entry : categoricalFunctionMap.entrySet()) { String key = entry.getKey(); if (input.containsKey(key)) { resultMap.put(key, entry.getValue().apply(input.get(key))); } } for (Map.Entry<String, Function<Map<String, Object>, Double>> entry : predictorTermsFunctionMap.entrySet()) { resultMap.put(entry.getKey(), entry.getValue().apply(input)); } resultMap.values().forEach(value -> result.accumulateAndGet(value, Double::sum)); updateResult(result); Object toReturn = result.get(); populateOutputFieldsMapWithResult(toReturn); return toReturn; }  abstract Object getTargetCategory(); Object evaluateRegression(Map<String, Object> input); Map<String, Object> getOutputFieldsMap(); String getTargetField(); Map<String, Function<Double, Double>> getNumericFunctionMap(); Map<String, Function<Object, Double>> getCategoricalFunctionMap(); Map<String, Function<Map<String, Object>, Double>> getPredictorTermsFunctionMap(); double getIntercept();  }
@Test public void evaluateRegression() { Map<String, Object> input = new HashMap<>(); input.put(FIRST_NUMERIC_INPUT, firstNumericalInput); input.put(SECOND_NUMERIC_INPUT, secondNumericalInput); input.put(FIRST_CATEGORICAL_INPUT, "unused"); input.put(SECOND_CATEGORICAL_INPUT, "unused"); Object retrieved = regressionTable.evaluateRegression(input); assertEquals(expectedResult, retrieved); final Map<String, Object> outputFieldsMap = regressionTable.getOutputFieldsMap(); assertTrue(outputFieldsMap.containsKey(TARGET_FIELD)); assertEquals(expectedResult, outputFieldsMap.get(TARGET_FIELD)); }