Search in sources :

Example 16 with DATA_TYPE

use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.

the class KiePMMLScorecardModelCharacteristicASTFactoryTest method getKiePMMLScorecardModelCharacteristicASTFactory.

private KiePMMLScorecardModelCharacteristicASTFactory getKiePMMLScorecardModelCharacteristicASTFactory() {
    final Map<String, KiePMMLOriginalTypeGeneratedType> fieldTypeMap = new HashMap<>();
    final List<Field<?>> fields = getFieldsFromDataDictionary(samplePmml.getDataDictionary());
    DATA_TYPE targetType = getTargetFieldType(fields, scorecardModel);
    KiePMMLDataDictionaryASTFactory.factory(fieldTypeMap).declareTypes(fields);
    assertFalse(fieldTypeMap.isEmpty());
    return KiePMMLScorecardModelCharacteristicASTFactory.factory(fieldTypeMap, Collections.emptyList(), targetType);
}
Also used : Field(org.dmg.pmml.Field) HashMap(java.util.HashMap) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) KiePMMLOriginalTypeGeneratedType(org.kie.pmml.models.drools.tuples.KiePMMLOriginalTypeGeneratedType)

Example 17 with DATA_TYPE

use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.

the class InstanceFactoriesTestCommon method commonVerifyKiePMMLDefineFunction.

static void commonVerifyKiePMMLDefineFunction(KiePMMLDefineFunction toVerify, DefineFunction source) {
    assertNotNull(toVerify);
    assertEquals(source.getName(), toVerify.getName());
    DATA_TYPE expectedDataType = DATA_TYPE.byName(source.getDataType().value());
    assertEquals(expectedDataType, toVerify.getDataType());
    OP_TYPE expectedOpType = OP_TYPE.byName(source.getOpType().value());
    assertEquals(expectedOpType, toVerify.getOpType());
    commonVerifyKiePMMLExpression(toVerify.getKiePMMLExpression(), source.getExpression());
    List<ParameterField> sourcesParameterFields = source.getParameterFields();
    List<KiePMMLParameterField> toVerifyList = toVerify.getParameterFields();
    assertEquals(sourcesParameterFields.size(), toVerifyList.size());
    sourcesParameterFields.forEach(paramSource -> {
        Optional<KiePMMLParameterField> parameterToVerify = toVerifyList.stream().filter(param -> param.getName().equals(paramSource.getName().getValue())).findFirst();
        assertTrue(parameterToVerify.isPresent());
        commonVerifyKiePMMLParameterField(parameterToVerify.get(), paramSource);
    });
}
Also used : Interval(org.dmg.pmml.Interval) KiePMMLParameterField(org.kie.pmml.commons.transformations.KiePMMLParameterField) FieldColumnPair(org.dmg.pmml.FieldColumnPair) KiePMMLMiningField(org.kie.pmml.commons.model.KiePMMLMiningField) NormDiscrete(org.dmg.pmml.NormDiscrete) KiePMMLInterval(org.kie.pmml.commons.model.expressions.KiePMMLInterval) KiePMMLTruePredicate(org.kie.pmml.commons.model.predicates.KiePMMLTruePredicate) OP_TYPE(org.kie.pmml.api.enums.OP_TYPE) Row(org.dmg.pmml.Row) KiePMMLOutputField(org.kie.pmml.commons.model.KiePMMLOutputField) KiePMMLInlineTable(org.kie.pmml.commons.model.expressions.KiePMMLInlineTable) KiePMMLLinearNorm(org.kie.pmml.commons.model.expressions.KiePMMLLinearNorm) KiePMMLNormContinuous(org.kie.pmml.commons.model.expressions.KiePMMLNormContinuous) DiscretizeBin(org.dmg.pmml.DiscretizeBin) KiePMMLRow(org.kie.pmml.commons.model.expressions.KiePMMLRow) Assert.fail(org.junit.Assert.fail) TextIndexNormalization(org.dmg.pmml.TextIndexNormalization) SimpleSetPredicate(org.dmg.pmml.SimpleSetPredicate) True(org.dmg.pmml.True) KiePMMLDiscretizeBin(org.kie.pmml.commons.model.expressions.KiePMMLDiscretizeBin) CompoundPredicate(org.dmg.pmml.CompoundPredicate) KiePMMLFieldColumnPair(org.kie.pmml.commons.model.expressions.KiePMMLFieldColumnPair) KiePMMLTargetValue(org.kie.pmml.commons.model.KiePMMLTargetValue) KiePMMLSimpleSetPredicate(org.kie.pmml.commons.model.predicates.KiePMMLSimpleSetPredicate) NormContinuous(org.dmg.pmml.NormContinuous) KiePMMLDiscretize(org.kie.pmml.commons.model.expressions.KiePMMLDiscretize) DataField(org.dmg.pmml.DataField) KiePMMLTextIndexNormalization(org.kie.pmml.commons.model.expressions.KiePMMLTextIndexNormalization) List(java.util.List) KiePMMLApply(org.kie.pmml.commons.model.expressions.KiePMMLApply) Optional(java.util.Optional) ParameterField(org.dmg.pmml.ParameterField) KiePMMLDerivedField(org.kie.pmml.commons.transformations.KiePMMLDerivedField) IntStream(java.util.stream.IntStream) KiePMMLConstant(org.kie.pmml.commons.model.expressions.KiePMMLConstant) Predicate(org.dmg.pmml.Predicate) DefineFunction(org.dmg.pmml.DefineFunction) InlineTable(org.dmg.pmml.InlineTable) OutputField(org.dmg.pmml.OutputField) KiePMMLMapValues(org.kie.pmml.commons.model.expressions.KiePMMLMapValues) KiePMMLNormDiscrete(org.kie.pmml.commons.model.expressions.KiePMMLNormDiscrete) DerivedField(org.dmg.pmml.DerivedField) CAST_INTEGER(org.kie.pmml.api.enums.CAST_INTEGER) Discretize(org.dmg.pmml.Discretize) KiePMMLFieldRef(org.kie.pmml.commons.model.expressions.KiePMMLFieldRef) MiningField(org.dmg.pmml.MiningField) KiePMMLExpression(org.kie.pmml.commons.model.expressions.KiePMMLExpression) TargetValue(org.dmg.pmml.TargetValue) KiePMMLDefineFunction(org.kie.pmml.commons.transformations.KiePMMLDefineFunction) Expression(org.dmg.pmml.Expression) False(org.dmg.pmml.False) KiePMMLSimplePredicate(org.kie.pmml.commons.model.predicates.KiePMMLSimplePredicate) Assert.assertNotNull(org.junit.Assert.assertNotNull) TextIndex(org.dmg.pmml.TextIndex) FieldRef(org.dmg.pmml.FieldRef) KiePMMLCompoundPredicate(org.kie.pmml.commons.model.predicates.KiePMMLCompoundPredicate) Assert.assertTrue(org.junit.Assert.assertTrue) StringEscapeUtils(org.apache.commons.text.StringEscapeUtils) Target(org.dmg.pmml.Target) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) KiePMMLPredicate(org.kie.pmml.commons.model.predicates.KiePMMLPredicate) Array(org.dmg.pmml.Array) SimplePredicate(org.dmg.pmml.SimplePredicate) KiePMMLTarget(org.kie.pmml.commons.model.KiePMMLTarget) KiePMMLTextIndex(org.kie.pmml.commons.model.expressions.KiePMMLTextIndex) LinearNorm(org.dmg.pmml.LinearNorm) MapValues(org.dmg.pmml.MapValues) Apply(org.dmg.pmml.Apply) EXPRESSION_NOT_MANAGED(org.kie.pmml.commons.Constants.EXPRESSION_NOT_MANAGED) Constant(org.dmg.pmml.Constant) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) KiePMMLFalsePredicate(org.kie.pmml.commons.model.predicates.KiePMMLFalsePredicate) Assert.assertEquals(org.junit.Assert.assertEquals) OP_TYPE(org.kie.pmml.api.enums.OP_TYPE) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) KiePMMLParameterField(org.kie.pmml.commons.transformations.KiePMMLParameterField) KiePMMLParameterField(org.kie.pmml.commons.transformations.KiePMMLParameterField) ParameterField(org.dmg.pmml.ParameterField)

Example 18 with DATA_TYPE

use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.

the class InstanceFactoriesTestCommon method commonVerifyKiePMMLDerivedField.

static void commonVerifyKiePMMLDerivedField(KiePMMLDerivedField toVerify, DerivedField source) {
    assertNotNull(toVerify);
    assertEquals(source.getName().getValue(), toVerify.getName());
    DATA_TYPE expectedDataType = DATA_TYPE.byName(source.getDataType().value());
    assertEquals(expectedDataType, toVerify.getDataType());
    OP_TYPE expectedOpType = OP_TYPE.byName(source.getOpType().value());
    assertEquals(expectedOpType, toVerify.getOpType());
    String expectedDisplayName = "Display-" + source.getName().getValue();
    assertEquals(expectedDisplayName, toVerify.getDisplayName());
    commonVerifyKiePMMLExpression(toVerify.getKiePMMLExpression(), source.getExpression());
}
Also used : OP_TYPE(org.kie.pmml.api.enums.OP_TYPE) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE)

Example 19 with DATA_TYPE

use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.

the class InstanceFactoriesTestCommon method commonVerifyKiePMMLParameterField.

static void commonVerifyKiePMMLParameterField(KiePMMLParameterField toVerify, ParameterField source) {
    assertNotNull(toVerify);
    assertEquals(source.getName().getValue(), toVerify.getName());
    DATA_TYPE expectedDataType = DATA_TYPE.byName(source.getDataType().value());
    assertEquals(expectedDataType, toVerify.getDataType());
    OP_TYPE expectedOpType = OP_TYPE.byName(source.getOpType().value());
    assertEquals(expectedOpType, toVerify.getOpType());
    String expectedDisplayName = "Display-" + source.getName().getValue();
    assertEquals(expectedDisplayName, toVerify.getDisplayName());
}
Also used : OP_TYPE(org.kie.pmml.api.enums.OP_TYPE) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE)

Example 20 with DATA_TYPE

use of org.kie.pmml.api.enums.DATA_TYPE in project drools by kiegroup.

the class ModelUtilsTest method convertToKieOutputField.

@Test
public void convertToKieOutputField() {
    final OutputField toConvert = getRandomOutputField();
    org.kie.pmml.api.models.OutputField retrieved = ModelUtils.convertToKieOutputField(toConvert, null);
    assertNotNull(retrieved);
    assertEquals(toConvert.getName().getValue(), retrieved.getName());
    OP_TYPE expectedOpType = OP_TYPE.byName(toConvert.getOpType().value());
    assertEquals(expectedOpType, retrieved.getOpType());
    DATA_TYPE expectedDataType = DATA_TYPE.byName(toConvert.getDataType().value());
    assertEquals(expectedDataType, retrieved.getDataType());
    assertEquals(toConvert.getTargetField().getValue(), retrieved.getTargetField());
    RESULT_FEATURE expectedResultFeature = RESULT_FEATURE.byName(toConvert.getResultFeature().value());
    assertEquals(expectedResultFeature, retrieved.getResultFeature());
    toConvert.setOpType(null);
    toConvert.setTargetField(null);
    retrieved = ModelUtils.convertToKieOutputField(toConvert, null);
    assertNull(retrieved.getOpType());
    assertNull(retrieved.getTargetField());
}
Also used : RESULT_FEATURE(org.kie.pmml.api.enums.RESULT_FEATURE) OutputField(org.dmg.pmml.OutputField) PMMLModelTestUtils.getRandomOutputField(org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getRandomOutputField) OP_TYPE(org.kie.pmml.api.enums.OP_TYPE) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) Test(org.junit.Test)

Aggregations

DATA_TYPE (org.kie.pmml.api.enums.DATA_TYPE)36 Test (org.junit.Test)17 OP_TYPE (org.kie.pmml.api.enums.OP_TYPE)15 DataField (org.dmg.pmml.DataField)10 ArrayList (java.util.ArrayList)9 HashMap (java.util.HashMap)8 Map (java.util.Map)8 INVALID_VALUE_TREATMENT_METHOD (org.kie.pmml.api.enums.INVALID_VALUE_TREATMENT_METHOD)8 MISSING_VALUE_TREATMENT_METHOD (org.kie.pmml.api.enums.MISSING_VALUE_TREATMENT_METHOD)8 KiePMMLException (org.kie.pmml.api.exceptions.KiePMMLException)8 List (java.util.List)7 MiningField (org.dmg.pmml.MiningField)7 KiePMMLMiningField (org.kie.pmml.commons.model.KiePMMLMiningField)7 KiePMMLInterval (org.kie.pmml.commons.model.expressions.KiePMMLInterval)7 KiePMMLDefineFunction (org.kie.pmml.commons.transformations.KiePMMLDefineFunction)7 KiePMMLParameterField (org.kie.pmml.commons.transformations.KiePMMLParameterField)7 Optional (java.util.Optional)6 Collectors (java.util.stream.Collectors)6 IntStream (java.util.stream.IntStream)6 Assert.assertEquals (org.junit.Assert.assertEquals)6