Search in sources :

Example 66 with PMMLRequestData

use of org.kie.api.pmml.PMMLRequestData in project drools by kiegroup.

the class PMMLRuntimeInternalImplTest method evaluateWithPMMLContextListeners.

@Test
public void evaluateWithPMMLContextListeners() {
    final PMMLRequestData requestData = getPMMLRequestData();
    final List<PMMLStep> pmmlSteps = new ArrayList<>();
    final PMMLContext pmmlContext = new PMMLContextImpl(requestData, Collections.singleton(getPMMLListener(pmmlSteps)));
    pmmlRuntime.evaluate(modelMock, pmmlContext);
    Arrays.stream(PMML_STEP.values()).forEach(pmml_step -> {
        Optional<PMMLStep> retrieved = pmmlSteps.stream().filter(pmmlStep -> pmml_step.equals(((PMMLRuntimeStep) pmmlStep).getPmmlStep())).findFirst();
        assertTrue(retrieved.isPresent());
        commonValuateStep(retrieved.get(), pmml_step, modelMock, requestData);
    });
}
Also used : IntStream(java.util.stream.IntStream) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) OK(org.kie.pmml.api.enums.ResultCode.OK) Arrays(java.util.Arrays) PMML4Result(org.kie.api.pmml.PMML4Result) PMML_STEP(org.kie.pmml.api.enums.PMML_STEP) ArrayList(java.util.ArrayList) MiningField(org.kie.pmml.api.models.MiningField) PMML_MODEL(org.kie.pmml.api.enums.PMML_MODEL) TestCase.assertNotNull(junit.framework.TestCase.assertNotNull) Map(java.util.Map) KiePMMLModel(org.kie.pmml.commons.model.KiePMMLModel) KieBase(org.kie.api.KieBase) Before(org.junit.Before) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) PMMLModelEvaluator(org.kie.pmml.evaluator.core.executor.PMMLModelEvaluator) Mockito.verify(org.mockito.Mockito.verify) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl) PMMLContext(org.kie.pmml.api.runtime.PMMLContext) List(java.util.List) Mockito.never(org.mockito.Mockito.never) PMMLRuntimeStep(org.kie.pmml.evaluator.core.implementations.PMMLRuntimeStep) PMMLRequestData(org.kie.api.pmml.PMMLRequestData) PMMLListener(org.kie.pmml.api.runtime.PMMLListener) PMMLModelEvaluatorFinderImpl(org.kie.pmml.evaluator.core.executor.PMMLModelEvaluatorFinderImpl) Optional(java.util.Optional) Collections(java.util.Collections) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) Mockito.reset(org.mockito.Mockito.reset) PMMLStep(org.kie.pmml.api.models.PMMLStep) TestCase.assertEquals(junit.framework.TestCase.assertEquals) Mockito.mock(org.mockito.Mockito.mock) PMMLRequestData(org.kie.api.pmml.PMMLRequestData) PMMLStep(org.kie.pmml.api.models.PMMLStep) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl) ArrayList(java.util.ArrayList) PMMLContext(org.kie.pmml.api.runtime.PMMLContext) Test(org.junit.Test)

Example 67 with PMMLRequestData

use of org.kie.api.pmml.PMMLRequestData in project drools by kiegroup.

the class PMMLScorecardModelEvaluatorTest method commonEvaluate.

private void commonEvaluate(Map<String, Object> inputData) {
    final PMMLRequestData pmmlRequestData = getPMMLRequestData(modelName, inputData);
    PMMLContext pmmlContext = new PMMLContextImpl(pmmlRequestData);
    commonEvaluate(pmmlContext);
}
Also used : PMMLRequestData(org.kie.api.pmml.PMMLRequestData) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl) PMMLContext(org.kie.pmml.api.runtime.PMMLContext)

Example 68 with PMMLRequestData

use of org.kie.api.pmml.PMMLRequestData in project drools by kiegroup.

the class PMMLTreeModelEvaluatorTest method commonEvaluate.

private void commonEvaluate(String modelName, Map<String, Object> inputData, String expectedScore) {
    final PMMLRequestData pmmlRequestData = getPMMLRequestData(modelName, inputData);
    PMMLContext pmmlContext = new PMMLContextImpl(pmmlRequestData);
    commonEvaluate(pmmlContext, expectedScore);
}
Also used : PMMLRequestData(org.kie.api.pmml.PMMLRequestData) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl) PMMLContext(org.kie.pmml.api.runtime.PMMLContext)

Aggregations

PMMLRequestData (org.kie.api.pmml.PMMLRequestData)68 Test (org.junit.Test)53 PMML4Result (org.kie.api.pmml.PMML4Result)30 DroolsAbstractPMMLTest (org.kie.pmml.pmml_4_2.DroolsAbstractPMMLTest)28 InternalRuleUnitExecutor (org.drools.core.impl.InternalRuleUnitExecutor)17 RuleUnitExecutor (org.kie.api.runtime.rule.RuleUnitExecutor)17 KieBase (org.kie.api.KieBase)16 KiePMMLMiningField (org.kie.pmml.commons.model.KiePMMLMiningField)16 ParameterInfo (org.kie.api.pmml.ParameterInfo)14 KiePMMLInterval (org.kie.pmml.commons.model.expressions.KiePMMLInterval)14 Map (java.util.Map)13 PMMLExecutor (org.kie.pmml.pmml_4_2.PMMLExecutor)11 ArrayList (java.util.ArrayList)9 Arrays (java.util.Arrays)9 Collections (java.util.Collections)9 List (java.util.List)9 Optional (java.util.Optional)9 IntStream (java.util.stream.IntStream)9 Assert.assertTrue (org.junit.Assert.assertTrue)9 DATA_TYPE (org.kie.pmml.api.enums.DATA_TYPE)9