use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.
the class PreProcessTest method verifyAddMissingValuesNotMissingNotReturnInvalidNotReplacement.
@Test
public void verifyAddMissingValuesNotMissingNotReturnInvalidNotReplacement() {
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.AS_IS).build();
}).collect(Collectors.toList());
PMMLRequestData pmmlRequestData = new PMMLRequestData("123", "modelName");
PreProcess.verifyAddMissingValues(miningFields, pmmlRequestData);
}
use of org.kie.pmml.api.enums.DATA_TYPE 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.api.enums.DATA_TYPE in project drools by kiegroup.
the class KiePMMLTreeModelNodeASTFactoryTest method declareIntermediateRuleFromGolfingNode.
@Test
public void declareIntermediateRuleFromGolfingNode() {
Node finalNode = golfingModel.getNode().getNodes().get(0);
assertEquals("will play", finalNode.getScore());
final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>();
final List<Field<?>> fields = getFieldsFromDataDictionary(golfingPmml.getDataDictionary());
DATA_TYPE targetType = getTargetFieldType(fields, golfingModel);
KiePMMLDataDictionaryASTFactory.factory(fieldTypeMap).declareTypes(fields);
final List<KiePMMLDroolsRule> rules = new ArrayList<>();
KiePMMLTreeModelNodeASTFactory.factory(fieldTypeMap, Collections.emptyList(), TreeModel.NoTrueChildStrategy.RETURN_NULL_PREDICTION, targetType).declareIntermediateRuleFromNode(finalNode, "_will play", rules);
assertFalse(rules.isEmpty());
}
use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.
the class KiePMMLTreeModelNodeASTFactoryTest method declareRulesFromRootGolfingNode.
@Test
public void declareRulesFromRootGolfingNode() {
Node rootNode = golfingModel.getNode();
assertEquals("will play", rootNode.getScore());
final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>();
final List<Field<?>> fields = getFieldsFromDataDictionary(golfingPmml.getDataDictionary());
DATA_TYPE targetType = getTargetFieldType(fields, golfingModel);
KiePMMLDataDictionaryASTFactory.factory(fieldTypeMap).declareTypes(fields);
KiePMMLTreeModelNodeASTFactory.factory(fieldTypeMap, Collections.emptyList(), TreeModel.NoTrueChildStrategy.RETURN_NULL_PREDICTION, targetType).declareRulesFromRootNode(rootNode, "_will");
assertFalse(fieldTypeMap.isEmpty());
}
use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.
the class KiePMMLTreeModelNodeASTFactoryTest method declareIntermediateRuleFromIrisNode.
@Test
public void declareIntermediateRuleFromIrisNode() {
Node finalNode = irisModel.getNode().getNodes().get(1);
assertEquals("versicolor", finalNode.getScore());
final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>();
final List<Field<?>> fields = getFieldsFromDataDictionary(irisPmml.getDataDictionary());
DATA_TYPE targetType = getTargetFieldType(fields, irisModel);
KiePMMLDataDictionaryASTFactory.factory(fieldTypeMap).declareTypes(fields);
final List<KiePMMLDroolsRule> rules = new ArrayList<>();
KiePMMLTreeModelNodeASTFactory.factory(fieldTypeMap, Collections.emptyList(), TreeModel.NoTrueChildStrategy.RETURN_NULL_PREDICTION, targetType).declareIntermediateRuleFromNode(finalNode, "_setosa", rules);
assertFalse(rules.isEmpty());
}
Aggregations