use of org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType in project drools by kiegroup.
the class KiePMMLTreeModelASTFactoryTest method getKiePMMLDroolsSimpleSetAST.
@Test
public void getKiePMMLDroolsSimpleSetAST() {
final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = getFieldTypeMap(simpleSetPmml.getDataDictionary(), simpleSetPmml.getTransformationDictionary(), simpleSetModel.getLocalTransformations());
List<KiePMMLDroolsType> types = Collections.emptyList();
KiePMMLDroolsAST retrieved = KiePMMLTreeModelASTFactory.getKiePMMLDroolsAST(getFieldsFromDataDictionary(simpleSetPmml.getDataDictionary()), simpleSetModel, fieldTypeMap, types);
assertNotNull(retrieved);
assertEquals(types, retrieved.getTypes());
assertFalse(retrieved.getRules().isEmpty());
}
use of org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType 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.models.drools.tuples.KiePMMLOriginalTypeGeneratedType 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.models.drools.tuples.KiePMMLOriginalTypeGeneratedType 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());
}
use of org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType in project drools by kiegroup.
the class KiePMMLDerivedFieldASTFactory method declareType.
/**
* Create a <code>KiePMMLDroolsType</code> out of original <code>DerivedField</code>,
* and <b>populate</b> the <b>fieldNameTypeNameMap</b> with mapping between original field' name and <b>original type/generated type</b> tupla
* @param derivedField
*/
public KiePMMLDroolsType declareType(DerivedField derivedField) {
String generatedType = getSanitizedClassName(derivedField.getName().getValue().toUpperCase());
String fieldName = derivedField.getName().getValue();
String fieldType = derivedField.getDataType().value();
fieldTypeMap.put(fieldName, new KiePMMLOriginalTypeGeneratedType(fieldType, generatedType));
return new KiePMMLDroolsType(generatedType, DATA_TYPE.byName(fieldType).getMappedClass().getSimpleName());
}
Aggregations