use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue 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.tuples.KiePMMLNameValue 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);
}
use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class KiePMMLMapValuesTest method evaluateKeyFoundNotMatching.
@Test
public void evaluateKeyFoundNotMatching() {
KiePMMLMapValues kiePMMLMapValues = getKiePMMLMapValues();
List<KiePMMLNameValue> kiePMMLNameValues = IntStream.range(0, 2).mapToObj(i -> new KiePMMLNameValue("FIELD-" + i, "NOT-VALUE-1-" + i)).collect(Collectors.toList());
ProcessingDTO processingDTO = getProcessingDTO(kiePMMLNameValues);
assertEquals(DEFAULTVALUE, kiePMMLMapValues.evaluate(processingDTO));
}
use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class KiePMMLOutputFieldTest method evaluatePredictedValue.
@Test
public void evaluatePredictedValue() {
final String variableName = "variableName";
KiePMMLOutputField kiePMMLOutputField = KiePMMLOutputField.builder("outputfield", Collections.emptyList()).withResultFeature(RESULT_FEATURE.PREDICTED_VALUE).withTargetField(variableName).build();
final List<KiePMMLNameValue> kiePMMLNameValues = IntStream.range(0, 3).mapToObj(i -> new KiePMMLNameValue("val-" + i, i)).collect(Collectors.toList());
ProcessingDTO processingDTO = getProcessingDTO(Collections.emptyList(), kiePMMLNameValues, Collections.emptyList());
assertNull(kiePMMLOutputField.evaluate(processingDTO));
final Object variableValue = 243.94;
kiePMMLNameValues.add(new KiePMMLNameValue(variableName, variableValue));
processingDTO = getProcessingDTO(Collections.emptyList(), kiePMMLNameValues, Collections.emptyList());
Object retrieved = kiePMMLOutputField.evaluate(processingDTO);
assertNotNull(retrieved);
assertEquals(variableValue, retrieved);
}
use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class KiePMMLOutputFieldTest method getValueFromKiePMMLNameValuesByVariableName.
@Test
public void getValueFromKiePMMLNameValuesByVariableName() {
final String variableName = "variableName";
final List<KiePMMLNameValue> kiePMMLNameValues = IntStream.range(0, 3).mapToObj(i -> new KiePMMLNameValue("val-" + i, i)).collect(Collectors.toList());
Optional<Object> retrieved = KiePMMLOutputField.getValueFromKiePMMLNameValuesByVariableName(variableName, kiePMMLNameValues);
assertFalse(retrieved.isPresent());
final Object variableValue = 243.94;
kiePMMLNameValues.add(new KiePMMLNameValue(variableName, variableValue));
retrieved = KiePMMLOutputField.getValueFromKiePMMLNameValuesByVariableName(variableName, kiePMMLNameValues);
assertTrue(retrieved.isPresent());
assertEquals(variableValue, retrieved.get());
}
Aggregations