Search in sources :

Example 16 with KiePMMLApply

use of org.kie.pmml.commons.model.expressions.KiePMMLApply in project drools by kiegroup.

the class KiePMMLDerivedFieldTest method evaluateFromApplyWithKiePMMLNameValues.

@Test
public void evaluateFromApplyWithKiePMMLNameValues() {
    // <DerivedField name="CUSTOM_FIELD" optype="continuous" dataType="double">
    // <Apply function="/">
    // <FieldRef>PARAM_1</FieldRef>
    // <FieldRef>PARAM_2</FieldRef>
    // </Apply>
    // </DerivedField>
    final KiePMMLFieldRef kiePMMLFieldRef1 = new KiePMMLFieldRef(PARAM_1, Collections.emptyList(), null);
    final KiePMMLFieldRef kiePMMLFieldRef2 = new KiePMMLFieldRef(PARAM_2, Collections.emptyList(), null);
    final KiePMMLApply kiePMMLApply = KiePMMLApply.builder("NAME", Collections.emptyList(), "/").withKiePMMLExpressions(Arrays.asList(kiePMMLFieldRef1, kiePMMLFieldRef2)).build();
    final KiePMMLDerivedField derivedField = KiePMMLDerivedField.builder(CUSTOM_FIELD, Collections.emptyList(), DATA_TYPE.DOUBLE, OP_TYPE.CONTINUOUS, kiePMMLApply).build();
    ProcessingDTO processingDTO = getProcessingDTO(Collections.emptyList(), getKiePMMLNameValues());
    Object retrieved = derivedField.evaluate(processingDTO);
    Object expected = value1 / value2;
    assertEquals(expected, retrieved);
}
Also used : CommonTestingUtility.getProcessingDTO(org.kie.pmml.commons.CommonTestingUtility.getProcessingDTO) ProcessingDTO(org.kie.pmml.commons.model.ProcessingDTO) KiePMMLApply(org.kie.pmml.commons.model.expressions.KiePMMLApply) KiePMMLFieldRef(org.kie.pmml.commons.model.expressions.KiePMMLFieldRef) Test(org.junit.Test)

Example 17 with KiePMMLApply

use of org.kie.pmml.commons.model.expressions.KiePMMLApply in project drools by kiegroup.

the class KiePMMLAttributeTest method getKiePMMLComplexPartialScore.

private KiePMMLComplexPartialScore getKiePMMLComplexPartialScore() {
    // <ComplexPartialScore>
    // <Apply function="/">
    // <FieldRef>PARAM_1</FieldRef>
    // <FieldRef>PARAM_2</FieldRef>
    // </Apply>
    // </ComplexPartialScore>
    final KiePMMLFieldRef kiePMMLFieldRef1 = new KiePMMLFieldRef(PARAM_1, Collections.emptyList(), null);
    final KiePMMLFieldRef kiePMMLFieldRef2 = new KiePMMLFieldRef(PARAM_2, Collections.emptyList(), null);
    final KiePMMLApply kiePMMLApply = KiePMMLApply.builder("NAME", Collections.emptyList(), "/").withKiePMMLExpressions(Arrays.asList(kiePMMLFieldRef1, kiePMMLFieldRef2)).build();
    return new KiePMMLComplexPartialScore(CUSTOM_FIELD, Collections.emptyList(), kiePMMLApply);
}
Also used : KiePMMLApply(org.kie.pmml.commons.model.expressions.KiePMMLApply) KiePMMLFieldRef(org.kie.pmml.commons.model.expressions.KiePMMLFieldRef)

Aggregations

KiePMMLApply (org.kie.pmml.commons.model.expressions.KiePMMLApply)17 Test (org.junit.Test)16 KiePMMLFieldRef (org.kie.pmml.commons.model.expressions.KiePMMLFieldRef)15 CommonTestingUtility.getProcessingDTO (org.kie.pmml.commons.CommonTestingUtility.getProcessingDTO)12 ProcessingDTO (org.kie.pmml.commons.model.ProcessingDTO)11 KiePMMLConstant (org.kie.pmml.commons.model.expressions.KiePMMLConstant)8 KiePMMLTestingModel (org.kie.pmml.commons.testingutility.KiePMMLTestingModel)8 PMML4Result (org.kie.api.pmml.PMML4Result)7 KiePMMLOutputField (org.kie.pmml.commons.model.KiePMMLOutputField)7 KiePMMLTransformationDictionary (org.kie.pmml.commons.transformations.KiePMMLTransformationDictionary)7 KiePMMLDerivedField (org.kie.pmml.commons.transformations.KiePMMLDerivedField)5 KiePMMLDefineFunction (org.kie.pmml.commons.transformations.KiePMMLDefineFunction)4 KiePMMLLocalTransformations (org.kie.pmml.commons.transformations.KiePMMLLocalTransformations)3 KiePMMLParameterField (org.kie.pmml.commons.transformations.KiePMMLParameterField)2 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Collections (java.util.Collections)1 List (java.util.List)1 Map (java.util.Map)1 Optional (java.util.Optional)1