use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class PMMLMiningModelEvaluatorTest method getPMML4ResultFAIL.
@Test
public void getPMML4ResultFAIL() {
String name = "NAME";
String targetField = "TARGET";
KiePMMLSegmentation kiePMMLSegmentation = KiePMMLSegmentation.builder("SEGM_1", Collections.emptyList(), AVERAGE).build();
KiePMMLMiningModel kiePMMLMiningModel = KiePMMLMiningModel.builder(name, Collections.emptyList(), MINING_FUNCTION.ASSOCIATION_RULES).withTargetField(targetField).withSegmentation(kiePMMLSegmentation).build();
final LinkedHashMap<String, PMMLMiningModelEvaluator.KiePMMLNameValueProbabilityMapTuple> inputData = new LinkedHashMap<>();
inputData.put("FIRST_KEY", new PMMLMiningModelEvaluator.KiePMMLNameValueProbabilityMapTuple(new KiePMMLNameValue("FIRST_NAME", "FIRST_VALUE"), new ArrayList<>()));
inputData.put("SECOND_KEY", new PMMLMiningModelEvaluator.KiePMMLNameValueProbabilityMapTuple(new KiePMMLNameValue("SECOND_NAME", "SECOND_VALUE"), new ArrayList<>()));
PMML4Result retrieved = evaluator.getPMML4Result(kiePMMLMiningModel, inputData, new PMMLContextTest());
assertNotNull(retrieved);
assertEquals(FAIL.getName(), retrieved.getResultCode());
assertEquals(targetField, retrieved.getResultObjectName());
final Map<String, Object> resultVariables = retrieved.getResultVariables();
assertTrue(resultVariables.containsKey(targetField));
assertNull(resultVariables.get(targetField));
}
use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class PMMLMiningModelEvaluatorTest method getKiePMMLNameValueValueWeightNumber.
@Test
public void getKiePMMLNameValueValueWeightNumber() {
final Integer rawObject = 24;
final PMML4Result pmml4Result = getPMML4Result(rawObject);
final double weight = 2.23;
double expected = rawObject.doubleValue();
VALUE_WEIGHT_METHODS.forEach(multipleModelMethod -> {
KiePMMLNameValue retrieved = evaluator.getKiePMMLNameValue(pmml4Result, multipleModelMethod, weight);
assertNotNull(retrieved);
assertEquals(pmml4Result.getResultObjectName(), retrieved.getName());
assertNotNull(retrieved.getValue());
assertTrue(retrieved.getValue() instanceof KiePMMLValueWeight);
KiePMMLValueWeight kiePMMLValueWeight = (KiePMMLValueWeight) retrieved.getValue();
assertEquals(expected, kiePMMLValueWeight.getValue(), 0.0);
assertEquals(weight, kiePMMLValueWeight.getWeight(), 0.0);
});
}
use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class MULTIPLE_MODEL_METHODTest method applyAVERAGENotKiePMMLValueWeight.
@Test(expected = KieEnumException.class)
public void applyAVERAGENotKiePMMLValueWeight() {
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"));
AVERAGE.applyPrediction(inputData);
}
use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class MULTIPLE_MODEL_METHODTest method applyWEIGHTED_SUMNotNumbers.
@Test(expected = KieEnumException.class)
public void applyWEIGHTED_SUMNotNumbers() {
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_SUM.applyPrediction(inputData);
}
use of org.kie.pmml.commons.model.tuples.KiePMMLNameValue in project drools by kiegroup.
the class MULTIPLE_MODEL_METHODTest method applyWEIGHTED_AVERAGENotKiePMMLValueWeight.
@Test(expected = KieEnumException.class)
public void applyWEIGHTED_AVERAGENotKiePMMLValueWeight() {
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_AVERAGE.applyPrediction(inputData);
}
Aggregations