use of org.kie.pmml.commons.model.KiePMMLMiningField in project drools by kiegroup.
the class PreProcessTest method verifyFixInvalidValuesInvalidReturnInvalid.
@Test(expected = KiePMMLException.class)
public void verifyFixInvalidValuesInvalidReturnInvalid() {
KiePMMLMiningField miningField0 = KiePMMLMiningField.builder("FIELD-0", null).withDataType(DATA_TYPE.STRING).withInvalidValueTreatmentMethod(INVALID_VALUE_TREATMENT_METHOD.RETURN_INVALID).withAllowedValues(Arrays.asList("123", "124", "125")).build();
KiePMMLMiningField miningField1 = KiePMMLMiningField.builder("FIELD-1", null).withDataType(DATA_TYPE.DOUBLE).withInvalidValueTreatmentMethod(INVALID_VALUE_TREATMENT_METHOD.RETURN_INVALID).withAllowedValues(Arrays.asList("1.23", "12.4", "1.25")).build();
List<KiePMMLInterval> intervals = Arrays.asList(new KiePMMLInterval(0.0, 12.4, CLOSURE.CLOSED_CLOSED), new KiePMMLInterval(12.6, 14.5, CLOSURE.OPEN_CLOSED));
KiePMMLMiningField miningField2 = KiePMMLMiningField.builder("FIELD-2", null).withDataType(DATA_TYPE.DOUBLE).withInvalidValueTreatmentMethod(INVALID_VALUE_TREATMENT_METHOD.RETURN_INVALID).withIntervals(intervals).build();
List<KiePMMLMiningField> miningFields = Arrays.asList(miningField0, miningField1, miningField2);
PMMLRequestData pmmlRequestData = new PMMLRequestData("123", "modelName");
pmmlRequestData.addRequestParam("FIELD-0", "122");
pmmlRequestData.addRequestParam("FIELD-1", 12.5);
pmmlRequestData.addRequestParam("FIELD-2", 14.6);
PreProcess.verifyFixInvalidValues(miningFields, pmmlRequestData);
}
use of org.kie.pmml.commons.model.KiePMMLMiningField in project drools by kiegroup.
the class PreProcessTest method verifyFixInvalidValuesInvalidAsIs.
@Test
public void verifyFixInvalidValuesInvalidAsIs() {
KiePMMLMiningField miningField0 = KiePMMLMiningField.builder("FIELD-0", null).withDataType(DATA_TYPE.STRING).withInvalidValueTreatmentMethod(INVALID_VALUE_TREATMENT_METHOD.AS_IS).withInvalidValueReplacement("123").withAllowedValues(Arrays.asList("123", "124", "125")).build();
KiePMMLMiningField miningField1 = KiePMMLMiningField.builder("FIELD-1", null).withDataType(DATA_TYPE.DOUBLE).withInvalidValueTreatmentMethod(INVALID_VALUE_TREATMENT_METHOD.AS_IS).withInvalidValueReplacement("1.23").withAllowedValues(Arrays.asList("1.23", "12.4", "1.25")).build();
List<KiePMMLInterval> intervals = Arrays.asList(new KiePMMLInterval(0.0, 12.4, CLOSURE.CLOSED_CLOSED), new KiePMMLInterval(12.6, 14.5, CLOSURE.OPEN_CLOSED));
KiePMMLMiningField miningField2 = KiePMMLMiningField.builder("FIELD-2", null).withDataType(DATA_TYPE.DOUBLE).withInvalidValueTreatmentMethod(INVALID_VALUE_TREATMENT_METHOD.AS_IS).withInvalidValueReplacement("12.3").withIntervals(intervals).build();
List<KiePMMLMiningField> miningFields = Arrays.asList(miningField0, miningField1, miningField2);
PMMLRequestData pmmlRequestData = new PMMLRequestData("123", "modelName");
pmmlRequestData.addRequestParam("FIELD-0", "122");
pmmlRequestData.addRequestParam("FIELD-1", 12.5);
pmmlRequestData.addRequestParam("FIELD-2", 14.6);
PreProcess.verifyFixInvalidValues(miningFields, pmmlRequestData);
Map<String, ParameterInfo> mappedRequestParams = pmmlRequestData.getMappedRequestParams();
assertEquals("122", mappedRequestParams.get("FIELD-0").getValue());
assertEquals(12.5, mappedRequestParams.get("FIELD-1").getValue());
assertEquals(14.6, mappedRequestParams.get("FIELD-2").getValue());
}
use of org.kie.pmml.commons.model.KiePMMLMiningField in project drools by kiegroup.
the class PreProcessTest method verifyAddMissingValuesNotMissingReturnInvalid.
@Test
public void verifyAddMissingValuesNotMissingReturnInvalid() {
List<KiePMMLMiningField> miningFields = IntStream.range(0, 3).mapToObj(i -> {
DATA_TYPE dataType = DATA_TYPE.values()[i];
return KiePMMLMiningField.builder("FIELD-" + i, null).withDataType(dataType).withMissingValueTreatmentMethod(MISSING_VALUE_TREATMENT_METHOD.RETURN_INVALID).build();
}).collect(Collectors.toList());
PMMLRequestData pmmlRequestData = new PMMLRequestData("123", "modelName");
pmmlRequestData.addRequestParam("FIELD-0", "123");
pmmlRequestData.addRequestParam("FIELD-1", 123);
pmmlRequestData.addRequestParam("FIELD-2", 1.23f);
PreProcess.verifyAddMissingValues(miningFields, pmmlRequestData);
}
use of org.kie.pmml.commons.model.KiePMMLMiningField in project drools by kiegroup.
the class PreProcessTest method verifyAddMissingValuesNotMissingNotReturnInvalidReplacement.
@Test
public void verifyAddMissingValuesNotMissingNotReturnInvalidReplacement() {
KiePMMLMiningField miningField0 = KiePMMLMiningField.builder("FIELD-0", null).withDataType(DATA_TYPE.STRING).withMissingValueTreatmentMethod(MISSING_VALUE_TREATMENT_METHOD.AS_IS).withMissingValueReplacement("123").withAllowedValues(Arrays.asList("123", "124", "125")).build();
KiePMMLMiningField miningField1 = KiePMMLMiningField.builder("FIELD-1", null).withDataType(DATA_TYPE.DOUBLE).withMissingValueTreatmentMethod(MISSING_VALUE_TREATMENT_METHOD.AS_IS).withMissingValueReplacement("1.23").withAllowedValues(Arrays.asList("1.23", "12.4", "1.25")).build();
List<KiePMMLInterval> intervals = Arrays.asList(new KiePMMLInterval(0.0, 12.4, CLOSURE.CLOSED_CLOSED), new KiePMMLInterval(12.6, 14.5, CLOSURE.OPEN_CLOSED));
KiePMMLMiningField miningField2 = KiePMMLMiningField.builder("FIELD-2", null).withDataType(DATA_TYPE.FLOAT).withMissingValueTreatmentMethod(MISSING_VALUE_TREATMENT_METHOD.AS_IS).withMissingValueReplacement("12.9").withIntervals(intervals).build();
List<KiePMMLMiningField> miningFields = Arrays.asList(miningField0, miningField1, miningField2);
PMMLRequestData pmmlRequestData = new PMMLRequestData("123", "modelName");
assertTrue(pmmlRequestData.getRequestParams().isEmpty());
PreProcess.verifyAddMissingValues(miningFields, pmmlRequestData);
Map<String, ParameterInfo> mappedRequestParams = pmmlRequestData.getMappedRequestParams();
assertEquals(miningFields.size(), mappedRequestParams.size());
assertEquals("123", mappedRequestParams.get("FIELD-0").getValue());
assertEquals(1.23, mappedRequestParams.get("FIELD-1").getValue());
assertEquals(12.9f, mappedRequestParams.get("FIELD-2").getValue());
}
use of org.kie.pmml.commons.model.KiePMMLMiningField in project drools by kiegroup.
the class PreProcessTest method manageInvalidValuesReturnInvalid.
@Test(expected = KiePMMLException.class)
public void manageInvalidValuesReturnInvalid() {
final ParameterInfo parameterInfo = new ParameterInfo();
// RETURN_INVALID
KiePMMLMiningField miningField = KiePMMLMiningField.builder("FIELD", null).withDataType(DATA_TYPE.STRING).withInvalidValueTreatmentMethod(INVALID_VALUE_TREATMENT_METHOD.RETURN_INVALID).build();
List<ParameterInfo> toRemove = new ArrayList<>();
PreProcess.manageInvalidValues(miningField, parameterInfo, toRemove);
}
Aggregations