use of org.kie.pmml.models.mining.model.KiePMMLMiningModel in project drools by kiegroup.
the class MiningModelImplementationProviderTest method commonGetKiePMMLModel.
private void commonGetKiePMMLModel(String source) throws Exception {
final PMML pmml = getPMML(source);
final KnowledgeBuilderImpl knowledgeBuilder = new KnowledgeBuilderImpl();
final MiningModel miningmodel = (MiningModel) pmml.getModels().get(0);
final CommonCompilationDTO<MiningModel> compilationDTO = CommonCompilationDTO.fromGeneratedPackageNameAndFields(PACKAGE_NAME, pmml, miningmodel, new HasKnowledgeBuilderMock(knowledgeBuilder));
final KiePMMLMiningModel retrieved = PROVIDER.getKiePMMLModel(compilationDTO);
assertNotNull(retrieved);
assertTrue(retrieved instanceof Serializable);
commonVerifyIsDeepCloneable(retrieved);
}
use of org.kie.pmml.models.mining.model.KiePMMLMiningModel 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.KiePMMLMiningModel in project drools by kiegroup.
the class PMMLMiningModelEvaluatorTest method validateKiePMMLMiningModel.
@Test
public void validateKiePMMLMiningModel() {
String name = "NAME";
KiePMMLMiningModel kiePMMLMiningModel = KiePMMLMiningModel.builder(name, Collections.emptyList(), MINING_FUNCTION.ASSOCIATION_RULES).withTargetField("TARGET").build();
evaluator.validate(kiePMMLMiningModel);
}
use of org.kie.pmml.models.mining.model.KiePMMLMiningModel in project drools by kiegroup.
the class PMMLMiningModelEvaluatorTest method validateMiningEmptyTargetField.
@Test(expected = KiePMMLInternalException.class)
public void validateMiningEmptyTargetField() {
String name = "NAME";
KiePMMLMiningModel kiePMMLMiningModel = KiePMMLMiningModel.builder(name, Collections.emptyList(), MINING_FUNCTION.ASSOCIATION_RULES).withTargetField(" ").build();
evaluator.validateMining(kiePMMLMiningModel);
}
use of org.kie.pmml.models.mining.model.KiePMMLMiningModel in project drools by kiegroup.
the class PMMLMiningModelEvaluatorTest method validateMiningNoTargetField.
@Test(expected = KiePMMLInternalException.class)
public void validateMiningNoTargetField() {
String name = "NAME";
KiePMMLMiningModel kiePMMLMiningModel = KiePMMLMiningModel.builder(name, Collections.emptyList(), MINING_FUNCTION.ASSOCIATION_RULES).build();
evaluator.validateMining(kiePMMLMiningModel);
}
Aggregations