Search in sources :

Example 31 with KiePMMLNameValue

use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.

the class MULTIPLE_MODEL_METHODTest method applyMEDIANNotNumbers.

@Test(expected = KieEnumException.class)
public void applyMEDIANNotNumbers() {
    LinkedHashMap<String, KiePMMLNameValue> inputData = new LinkedHashMap<>();
    Object EXPECTED = "EXPECTED";
    inputData.put("ValueA", new KiePMMLNameValue("valuea", "dvsdv"));
    inputData.put("ValueB", new KiePMMLNameValue("valueb", EXPECTED));
    inputData.put("ValueC", new KiePMMLNameValue("valuec", "dssd"));
    inputData.put("ValueD", new KiePMMLNameValue("valuex", EXPECTED));
    inputData.put("ValueE", new KiePMMLNameValue("valueb", "vsd"));
    MEDIAN.applyPrediction(inputData);
}
Also used : KiePMMLNameValue(org.kie.pmml.commons.model.tuples.KiePMMLNameValue) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 32 with KiePMMLNameValue

use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.

the class MULTIPLE_MODEL_METHODTest method applySELECT_ALLNotNumbers.

@Test
public void applySELECT_ALLNotNumbers() {
    LinkedHashMap<String, KiePMMLNameValue> inputData = new LinkedHashMap<>();
    inputData.put("ValueA", new KiePMMLNameValue("valuea", "fvdsfsdfsd"));
    inputData.put("ValueB", new KiePMMLNameValue("valueb", "vdsvsd"));
    inputData.put("ValueC", new KiePMMLNameValue("valuec", "dssd"));
    inputData.put("ValueD", new KiePMMLNameValue("valuex", "vfdsvsdeeee"));
    inputData.put("ValueE", new KiePMMLNameValue("valueb", "vsd"));
    List expected = inputData.values().stream().map(KiePMMLNameValue::getValue).collect(Collectors.toList());
    List retrieved = (List) SELECT_ALL.applyPrediction(inputData);
    assertEquals(expected.size(), retrieved.size());
    expected.forEach(expString -> assertTrue(retrieved.contains(expString)));
}
Also used : KiePMMLNameValue(org.kie.pmml.commons.model.tuples.KiePMMLNameValue) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 33 with KiePMMLNameValue

use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.

the class MULTIPLE_MODEL_METHODTest method applySUMNotNumbers.

@Test(expected = KieEnumException.class)
public void applySUMNotNumbers() {
    LinkedHashMap<String, KiePMMLNameValue> inputData = new LinkedHashMap<>();
    Object EXPECTED = "EXPECTED";
    inputData.put("ValueA", new KiePMMLNameValue("valuea", "dvsdv"));
    inputData.put("ValueB", new KiePMMLNameValue("valueb", EXPECTED));
    inputData.put("ValueC", new KiePMMLNameValue("valuec", "dssd"));
    inputData.put("ValueD", new KiePMMLNameValue("valuex", EXPECTED));
    inputData.put("ValueE", new KiePMMLNameValue("valueb", "vsd"));
    SUM.applyPrediction(inputData);
}
Also used : KiePMMLNameValue(org.kie.pmml.commons.model.tuples.KiePMMLNameValue) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 34 with KiePMMLNameValue

use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.

the class MULTIPLE_MODEL_METHODTest method applyWEIGHTED_MEDIANNotNumbers.

@Test(expected = KieEnumException.class)
public void applyWEIGHTED_MEDIANNotNumbers() {
    LinkedHashMap<String, KiePMMLNameValue> inputData = new LinkedHashMap<>();
    Object EXPECTED = "EXPECTED";
    inputData.put("ValueA", new KiePMMLNameValue("valuea", "dvsdv"));
    inputData.put("ValueB", new KiePMMLNameValue("valueb", EXPECTED));
    inputData.put("ValueC", new KiePMMLNameValue("valuec", "dssd"));
    inputData.put("ValueD", new KiePMMLNameValue("valuex", EXPECTED));
    inputData.put("ValueE", new KiePMMLNameValue("valueb", "vsd"));
    WEIGHTED_MEDIAN.applyPrediction(inputData);
}
Also used : KiePMMLNameValue(org.kie.pmml.commons.model.tuples.KiePMMLNameValue) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 35 with KiePMMLNameValue

use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.

the class KiePMMLOutputFieldTest method evaluateTransformedValueFromFieldRef.

@Test
public void evaluateTransformedValueFromFieldRef() {
    // <OutputField name="CUSTOM_FIELD" optype="continuous" dataType="double" feature="transformedValue">
    // <FieldRef field="PARAM_1"/>
    // </OutputField>
    final KiePMMLFieldRef kiePMMLFieldRef = new KiePMMLFieldRef(PARAM_1, Collections.emptyList(), null);
    final KiePMMLOutputField outputField = KiePMMLOutputField.builder(CUSTOM_FIELD, Collections.emptyList()).withKiePMMLExpression(kiePMMLFieldRef).withResultFeature(RESULT_FEATURE.TRANSFORMED_VALUE).build();
    ProcessingDTO processingDTO = getProcessingDTO(Collections.emptyList(), Arrays.asList(new KiePMMLNameValue(PARAM_1, value1)), Collections.emptyList());
    Object retrieved = outputField.evaluate(processingDTO);
    assertEquals(value1, retrieved);
}
Also used : CommonTestingUtility.getProcessingDTO(org.kie.pmml.commons.CommonTestingUtility.getProcessingDTO) KiePMMLNameValue(org.kie.pmml.commons.model.tuples.KiePMMLNameValue) KiePMMLFieldRef(org.kie.pmml.commons.model.expressions.KiePMMLFieldRef) Test(org.junit.Test)

Aggregations

KiePMMLNameValue (org.kie.pmml.commons.model.tuples.KiePMMLNameValue)44 Test (org.junit.Test)37 CommonTestingUtility.getProcessingDTO (org.kie.pmml.commons.CommonTestingUtility.getProcessingDTO)19 ProcessingDTO (org.kie.pmml.commons.model.ProcessingDTO)19 LinkedHashMap (java.util.LinkedHashMap)16 ArrayList (java.util.ArrayList)8 List (java.util.List)8 HashMap (java.util.HashMap)7 PMML4Result (org.kie.api.pmml.PMML4Result)7 Map (java.util.Map)6 Collectors (java.util.stream.Collectors)6 IntStream (java.util.stream.IntStream)6 Assert.assertEquals (org.junit.Assert.assertEquals)6 KiePMMLFieldRef (org.kie.pmml.commons.model.expressions.KiePMMLFieldRef)6 KiePMMLDerivedField (org.kie.pmml.commons.transformations.KiePMMLDerivedField)6 Collections (java.util.Collections)5 Assert.assertNotNull (org.junit.Assert.assertNotNull)5 Arrays (java.util.Arrays)4 Assert.assertTrue (org.junit.Assert.assertTrue)4 PMMLContextTest (org.kie.pmml.commons.testingutility.PMMLContextTest)4