use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class MULTIPLE_MODEL_METHODTest method applyWEIGHTED_MAJORITY_VOTE.
@Test(expected = KieEnumException.class)
public void applyWEIGHTED_MAJORITY_VOTE() {
LinkedHashMap<String, KiePMMLNameValue> inputData = new LinkedHashMap<>();
Object EXPECTED = 3;
inputData.put("ValueA", new KiePMMLNameValue("valuea", 1));
inputData.put("ValueB", new KiePMMLNameValue("valueb", EXPECTED));
inputData.put("ValueC", new KiePMMLNameValue("valuec", EXPECTED));
inputData.put("ValueD", new KiePMMLNameValue("valuex", EXPECTED));
inputData.put("ValueE", new KiePMMLNameValue("valueb", 1));
WEIGHTED_MAJORITY_VOTE.applyPrediction(inputData);
}
use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class MULTIPLE_MODEL_METHODTest method applyMAJORITY_VOTE.
@Test
public void applyMAJORITY_VOTE() {
LinkedHashMap<String, KiePMMLNameValue> inputData = new LinkedHashMap<>();
Object EXPECTED = 3;
inputData.put("ValueA", new KiePMMLNameValue("valuea", 1));
inputData.put("ValueB", new KiePMMLNameValue("valueb", EXPECTED));
inputData.put("ValueC", new KiePMMLNameValue("valuec", EXPECTED));
inputData.put("ValueD", new KiePMMLNameValue("valuex", EXPECTED));
inputData.put("ValueE", new KiePMMLNameValue("valueb", 1));
Object retrieved = MAJORITY_VOTE.applyPrediction(inputData);
assertEquals(EXPECTED, retrieved);
inputData = new LinkedHashMap<>();
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"));
retrieved = MAJORITY_VOTE.applyPrediction(inputData);
assertEquals(EXPECTED, retrieved);
}
use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class MULTIPLE_MODEL_METHODTest method applyMAXNotNumbers.
@Test(expected = KieEnumException.class)
public void applyMAXNotNumbers() {
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"));
MAX.applyPrediction(inputData);
}
use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class MULTIPLE_MODEL_METHODTest method applySELECT_FIRSTNotNumbers.
@Test
public void applySELECT_FIRSTNotNumbers() {
LinkedHashMap<String, KiePMMLNameValue> inputData = new LinkedHashMap<>();
Object EXPECTED = "EXPECTED";
inputData.put("ValueA", new KiePMMLNameValue("valuea", EXPECTED));
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"));
Object retrieved = SELECT_FIRST.applyPrediction(inputData);
assertEquals(EXPECTED, retrieved);
}
use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class MULTIPLE_MODEL_METHODTest method applySELECT_ALLNumbers.
@Test
public void applySELECT_ALLNumbers() {
Map<String, Object> expectedKiePMMLValueWeightMap = getExpectedKiePMMLValueWeightMap(true);
LinkedHashMap<String, KiePMMLNameValue> inputData = (LinkedHashMap<String, KiePMMLNameValue>) expectedKiePMMLValueWeightMap.get("inputData");
List<Double> expected = inputData.values().stream().map(kiePMMLNameValue -> ((KiePMMLValueWeight) kiePMMLNameValue.getValue()).getValue()).collect(Collectors.toList());
List retrieved = (List) SELECT_ALL.applyPrediction(inputData);
assertEquals(expected.size(), retrieved.size());
for (Double expDouble : expected) {
assertTrue(retrieved.contains(expDouble));
}
expectedKiePMMLValueWeightMap = getExpectedKiePMMLValueWeightMap(false);
inputData = (LinkedHashMap<String, KiePMMLNameValue>) expectedKiePMMLValueWeightMap.get("inputData");
expected = inputData.values().stream().map(kiePMMLNameValue -> ((KiePMMLValueWeight) kiePMMLNameValue.getValue()).getValue()).collect(Collectors.toList());
retrieved = (List) SELECT_ALL.applyPrediction(inputData);
assertEquals(expected.size(), retrieved.size());
for (Double expDouble : expected) {
assertTrue(retrieved.contains(expDouble));
}
}
Aggregations