use of org.kie.pmml.models.mining.model.segmentation.KiePMMLSegmentation 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.models.mining.model.segmentation.KiePMMLSegmentation in project drools by kiegroup.
the class KiePMMLMiningModelTest method getSegmentation.
@Test
public void getSegmentation() {
assertNull(KIE_PMML_MINING_MODEL.getSegmentation());
final KiePMMLSegmentation segmentation = getKiePMMLSegmentation("SEGMENTATION_NAME");
KIE_PMML_MINING_MODEL = BUILDER.withSegmentation(segmentation).build();
assertEquals(segmentation, KIE_PMML_MINING_MODEL.getSegmentation());
}
use of org.kie.pmml.models.mining.model.segmentation.KiePMMLSegmentation in project drools by kiegroup.
the class PMMLMiningModelEvaluatorTest method getPMML4ResultOK.
@Test
public void getPMML4ResultOK() {
String name = "NAME";
String targetField = "TARGET";
String prediction = "FIRST_VALUE";
KiePMMLSegmentation kiePMMLSegmentation = KiePMMLSegmentation.builder("SEGM_1", Collections.emptyList(), SELECT_FIRST).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", prediction), 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(OK.getName(), retrieved.getResultCode());
assertEquals(targetField, retrieved.getResultObjectName());
final Map<String, Object> resultVariables = retrieved.getResultVariables();
assertTrue(resultVariables.containsKey(targetField));
assertEquals(prediction, resultVariables.get(targetField));
}
Aggregations