use of org.dmg.pmml.regression.NumericPredictor 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.dmg.pmml.regression.NumericPredictor in project drools by kiegroup.
the class KiePMMLRegressionTableFactoryTest method getNumericPredictorEntryWithExponent.
@Test
public void getNumericPredictorEntryWithExponent() {
String predictorName = "predictorName";
int exponent = 2;
double coefficient = 1.23;
NumericPredictor numericPredictor = PMMLModelTestUtils.getNumericPredictor(predictorName, exponent, coefficient);
SerializableFunction<Double, Double> retrieved = KiePMMLRegressionTableFactory.getNumericPredictorEntry(numericPredictor);
assertNotNull(retrieved);
}
use of org.dmg.pmml.regression.NumericPredictor in project drools by kiegroup.
the class KiePMMLRegressionTableFactoryTest method getNumericPredictorEntryWithoutExponent.
@Test
public void getNumericPredictorEntryWithoutExponent() {
String predictorName = "predictorName";
int exponent = 1;
double coefficient = 1.23;
NumericPredictor numericPredictor = PMMLModelTestUtils.getNumericPredictor(predictorName, exponent, coefficient);
SerializableFunction<Double, Double> retrieved = KiePMMLRegressionTableFactory.getNumericPredictorEntry(numericPredictor);
assertNotNull(retrieved);
}
use of org.dmg.pmml.regression.NumericPredictor in project drools by kiegroup.
the class KiePMMLRegressionTableFactoryTest method getNumericPredictorExpressionWithoutExponent.
@Test
public void getNumericPredictorExpressionWithoutExponent() throws IOException {
String predictorName = "predictorName";
int exponent = 1;
double coefficient = 1.23;
NumericPredictor numericPredictor = PMMLModelTestUtils.getNumericPredictor(predictorName, exponent, coefficient);
CastExpr retrieved = KiePMMLRegressionTableFactory.getNumericPredictorExpression(numericPredictor);
String text = getFileContent(TEST_02_SOURCE);
Expression expected = JavaParserUtils.parseExpression(String.format(text, coefficient));
assertTrue(JavaParserUtils.equalsNode(expected, retrieved));
}
use of org.dmg.pmml.regression.NumericPredictor in project drools by kiegroup.
the class PMMLModelTestUtils method getNumericPredictor.
public static NumericPredictor getNumericPredictor(String name, int exponent, double coefficient) {
NumericPredictor toReturn = new NumericPredictor();
toReturn.setField(FieldName.create(name));
toReturn.setExponent(exponent);
toReturn.setCoefficient(coefficient);
return toReturn;
}
Aggregations