use of org.kie.pmml.api.iinterfaces.SerializableFunction in project drools by kiegroup.
the class KiePMMLRegressionModelFactoryTest method evaluateRegressionTable.
private void evaluateRegressionTable(KiePMMLRegressionTable regressionTable, RegressionTable originalRegressionTable) {
assertEquals(originalRegressionTable.getIntercept(), regressionTable.getIntercept());
final Map<String, SerializableFunction<Double, Double>> numericFunctionMap = regressionTable.getNumericFunctionMap();
for (NumericPredictor numericPredictor : originalRegressionTable.getNumericPredictors()) {
assertTrue(numericFunctionMap.containsKey(numericPredictor.getName().getValue()));
}
final Map<String, SerializableFunction<String, Double>> categoricalFunctionMap = regressionTable.getCategoricalFunctionMap();
for (CategoricalPredictor categoricalPredictor : originalRegressionTable.getCategoricalPredictors()) {
assertTrue(categoricalFunctionMap.containsKey(categoricalPredictor.getName().getValue()));
}
final Map<String, SerializableFunction<Map<String, Object>, Double>> predictorTermsFunctionMap = regressionTable.getPredictorTermsFunctionMap();
for (PredictorTerm predictorTerm : originalRegressionTable.getPredictorTerms()) {
assertTrue(predictorTermsFunctionMap.containsKey(predictorTerm.getName().getValue()));
}
}
use of org.kie.pmml.api.iinterfaces.SerializableFunction in project drools by kiegroup.
the class KiePMMLRegressionTableFactoryTest method getPredictorTermsMap.
@Test
public void getPredictorTermsMap() {
final List<PredictorTerm> predictorTerms = IntStream.range(0, 3).mapToObj(index -> {
String predictorName = "predictorName-" + index;
double coefficient = 1.23 * index;
String fieldRef = "fieldRef-" + index;
return PMMLModelTestUtils.getPredictorTerm(predictorName, coefficient, Collections.singletonList(fieldRef));
}).collect(Collectors.toList());
Map<String, SerializableFunction<Map<String, Object>, Double>> retrieved = KiePMMLRegressionTableFactory.getPredictorTermsMap(predictorTerms);
assertEquals(predictorTerms.size(), retrieved.size());
IntStream.range(0, predictorTerms.size()).forEach(index -> {
PredictorTerm predictorTerm = predictorTerms.get(index);
assertTrue(retrieved.containsKey(predictorTerm.getName().getValue()));
});
}
Aggregations