use of org.kie.pmml.commons.model.ProcessingDTO in project drools by kiegroup.
the class KiePMMLDerivedFieldTest method evaluateFromConstant.
@Test
public void evaluateFromConstant() {
// <DerivedField name="CUSTOM_FIELD" optype="continuous" dataType="double">
// <Constant>100.0</Constant>
// </DerivedField>
final KiePMMLConstant kiePMMLConstant1 = new KiePMMLConstant(PARAM_1, Collections.emptyList(), value1, null);
final KiePMMLDerivedField derivedField = KiePMMLDerivedField.builder(CUSTOM_FIELD, Collections.emptyList(), DATA_TYPE.DOUBLE, OP_TYPE.CONTINUOUS, kiePMMLConstant1).build();
ProcessingDTO processingDTO = getProcessingDTO(Collections.emptyList(), new ArrayList<>());
Object retrieved = derivedField.evaluate(processingDTO);
assertEquals(value1, retrieved);
}
use of org.kie.pmml.commons.model.ProcessingDTO in project drools by kiegroup.
the class KiePMMLDerivedFieldTest method evaluateFromApplyWithDerivedFields.
@Test
public void evaluateFromApplyWithDerivedFields() {
// <DerivedField name="CUSTOM_FIELD" optype="continuous" dataType="double">
// <Apply function="/">
// <FieldRef>PARAM_1</FieldRef>
// <FieldRef>PARAM_2</FieldRef>
// </Apply>
// </DerivedField>
final KiePMMLFieldRef kiePMMLFieldRef1 = new KiePMMLFieldRef(PARAM_1, Collections.emptyList(), null);
final KiePMMLFieldRef kiePMMLFieldRef2 = new KiePMMLFieldRef(PARAM_2, Collections.emptyList(), null);
final KiePMMLApply kiePMMLApply = KiePMMLApply.builder("NAME", Collections.emptyList(), "/").withKiePMMLExpressions(Arrays.asList(kiePMMLFieldRef1, kiePMMLFieldRef2)).build();
final KiePMMLDerivedField derivedField = KiePMMLDerivedField.builder(CUSTOM_FIELD, Collections.emptyList(), DATA_TYPE.DOUBLE, OP_TYPE.CONTINUOUS, kiePMMLApply).build();
ProcessingDTO processingDTO = getProcessingDTO(getDerivedFields(), new ArrayList<>());
Object retrieved = derivedField.evaluate(processingDTO);
Object expected = value1 / value2;
assertEquals(expected, retrieved);
}
use of org.kie.pmml.commons.model.ProcessingDTO in project drools by kiegroup.
the class KiePMMLDiscretizeTest method evaluateNoInput.
@Test
public void evaluateNoInput() {
KiePMMLDiscretize kiePMMLDiscretize = getKiePMMLDiscretize(null, null);
ProcessingDTO processingDTO = getProcessingDTO(Collections.emptyList());
Object retrieved = kiePMMLDiscretize.evaluate(processingDTO);
assertNull(retrieved);
kiePMMLDiscretize = getKiePMMLDiscretize(MAP_MISSING_TO, null);
retrieved = kiePMMLDiscretize.evaluate(processingDTO);
assertNotNull(retrieved);
assertEquals(MAP_MISSING_TO, retrieved);
}
use of org.kie.pmml.commons.model.ProcessingDTO in project drools by kiegroup.
the class KiePMMLDiscretizeTest method evaluateDefaultValue.
@Test
public void evaluateDefaultValue() {
KiePMMLDiscretize kiePMMLDiscretize = getKiePMMLDiscretize(null, null);
ProcessingDTO processingDTO = getProcessingDTO(Arrays.asList(new KiePMMLNameValue(NAME, 20)));
Object retrieved = kiePMMLDiscretize.evaluate(processingDTO);
assertNull(retrieved);
kiePMMLDiscretize = getKiePMMLDiscretize(MAP_MISSING_TO, DEFAULTVALUE);
processingDTO = getProcessingDTO(Arrays.asList(new KiePMMLNameValue(NAME, 20)));
retrieved = kiePMMLDiscretize.evaluate(processingDTO);
assertNotNull(retrieved);
assertEquals(DEFAULTVALUE, retrieved);
processingDTO = getProcessingDTO(Arrays.asList(new KiePMMLNameValue(NAME, 21)));
retrieved = kiePMMLDiscretize.evaluate(processingDTO);
assertNotNull(retrieved);
assertEquals(DEFAULTVALUE, retrieved);
processingDTO = getProcessingDTO(Arrays.asList(new KiePMMLNameValue(NAME, 40)));
retrieved = kiePMMLDiscretize.evaluate(processingDTO);
assertNotNull(retrieved);
assertEquals(DEFAULTVALUE, retrieved);
}
use of org.kie.pmml.commons.model.ProcessingDTO in project drools by kiegroup.
the class KiePMMLMapValuesTest method evaluateKeyFoundMatching.
@Test
public void evaluateKeyFoundMatching() {
KiePMMLMapValues kiePMMLMapValues = getKiePMMLMapValues();
List<KiePMMLNameValue> kiePMMLNameValues = IntStream.range(0, 2).mapToObj(i -> new KiePMMLNameValue("FIELD-" + i, "VALUE-1-" + i)).collect(Collectors.toList());
ProcessingDTO processingDTO = getProcessingDTO(kiePMMLNameValues);
Object retrieved = kiePMMLMapValues.evaluate(processingDTO);
assertNotNull(retrieved);
}
Aggregations