Search in sources :

Example 11 with OP_TYPE

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

the class KiePMMLLoadedModelUtilsTest method getOpTypeFromDataFieldExisting.

@Test
public void getOpTypeFromDataFieldExisting() throws Exception {
    pmmlModel = KiePMMLUtil.load(getFileInputStream(NO_TARGET_SOURCE), NO_TARGET_SOURCE);
    final OP_TYPE retrieved = getOpType(getFieldsFromDataDictionary(pmmlModel.getDataDictionary()), pmmlModel.getModels().get(0), TEMPERATURE_FIELD);
    assertNotNull(retrieved);
    assertEquals(CONTINUOUS, retrieved);
}
Also used : OP_TYPE(org.kie.pmml.api.enums.OP_TYPE) Test(org.junit.Test)

Example 12 with OP_TYPE

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

the class KiePMMLLoadedModelUtilsTest method getOpTypeFromMiningFieldExisting.

@Test
public void getOpTypeFromMiningFieldExisting() throws Exception {
    pmmlModel = KiePMMLUtil.load(getFileInputStream(ONE_MINING_TARGET_SOURCE), ONE_MINING_TARGET_SOURCE);
    final OP_TYPE retrieved = getOpType(getFieldsFromDataDictionary(pmmlModel.getDataDictionary()), pmmlModel.getModels().get(0), OUTLOOK_FIELD);
    assertNotNull(retrieved);
    assertEquals(CATEGORICAL, retrieved);
}
Also used : OP_TYPE(org.kie.pmml.api.enums.OP_TYPE) Test(org.junit.Test)

Example 13 with OP_TYPE

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

the class RegressionModelImplementationProvider method validateClassification.

private void validateClassification(final List<Field<?>> fields, final RegressionModel toValidate) {
    final String categoricalTargeName = getCategoricalTargetName(fields, toValidate);
    final OP_TYPE opType = getOpType(fields, toValidate, categoricalTargeName);
    switch(opType) {
        case CATEGORICAL:
            validateClassificationCategorical(fields, toValidate, categoricalTargeName);
            break;
        case ORDINAL:
            validateClassificationOrdinal(toValidate);
            break;
        default:
            throw new KiePMMLException("Invalid target type " + opType);
    }
}
Also used : KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) OP_TYPE(org.kie.pmml.api.enums.OP_TYPE)

Example 14 with OP_TYPE

use of org.kie.pmml.api.enums.OP_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 15 with OP_TYPE

use of org.kie.pmml.api.enums.OP_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)

Aggregations

OP_TYPE (org.kie.pmml.api.enums.OP_TYPE)31 DATA_TYPE (org.kie.pmml.api.enums.DATA_TYPE)14 DataField (org.dmg.pmml.DataField)13 Test (org.junit.Test)13 MiningField (org.dmg.pmml.MiningField)12 DataDictionary (org.dmg.pmml.DataDictionary)8 MiningSchema (org.dmg.pmml.MiningSchema)8 OutputField (org.dmg.pmml.OutputField)8 CommonTestingUtils.getFieldsFromDataDictionary (org.kie.pmml.compiler.api.CommonTestingUtils.getFieldsFromDataDictionary)8 PMMLModelTestUtils.getDataField (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getDataField)8 PMMLModelTestUtils.getMiningField (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getMiningField)8 PMMLModelTestUtils.getRandomDataField (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getRandomDataField)8 PMMLModelTestUtils.getRandomMiningField (org.kie.pmml.compiler.api.testutils.PMMLModelTestUtils.getRandomMiningField)8 Model (org.dmg.pmml.Model)7 Target (org.dmg.pmml.Target)7 RegressionModel (org.dmg.pmml.regression.RegressionModel)7 FIELD_USAGE_TYPE (org.kie.pmml.api.enums.FIELD_USAGE_TYPE)7 DataType (org.dmg.pmml.DataType)6 DerivedField (org.dmg.pmml.DerivedField)6 ParameterField (org.dmg.pmml.ParameterField)6