Search in sources :

Example 61 with PMMLRequestData

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

the class PreProcessTest method verifyAddMissingValuesMissingReturnInvalid.

@Test(expected = KiePMMLException.class)
public void verifyAddMissingValuesMissingReturnInvalid() {
    List<KiePMMLMiningField> miningFields = IntStream.range(0, 3).mapToObj(i -> {
        DATA_TYPE dataType = DATA_TYPE.values()[i];
        return KiePMMLMiningField.builder("FIELD-" + i, null).withDataType(dataType).withMissingValueTreatmentMethod(MISSING_VALUE_TREATMENT_METHOD.RETURN_INVALID).build();
    }).collect(Collectors.toList());
    PMMLRequestData pmmlRequestData = new PMMLRequestData("123", "modelName");
    PreProcess.verifyAddMissingValues(miningFields, pmmlRequestData);
}
Also used : IntStream(java.util.stream.IntStream) CLOSURE(org.kie.pmml.api.enums.CLOSURE) KiePMMLConstant(org.kie.pmml.commons.model.expressions.KiePMMLConstant) Arrays(java.util.Arrays) KiePMMLParameterField(org.kie.pmml.commons.transformations.KiePMMLParameterField) KiePMMLMiningField(org.kie.pmml.commons.model.KiePMMLMiningField) KiePMMLInterval(org.kie.pmml.commons.model.expressions.KiePMMLInterval) OP_TYPE(org.kie.pmml.api.enums.OP_TYPE) ArrayList(java.util.ArrayList) MiningField(org.kie.pmml.api.models.MiningField) KiePMMLNameValue(org.kie.pmml.commons.model.tuples.KiePMMLNameValue) KiePMMLTransformationDictionary(org.kie.pmml.commons.transformations.KiePMMLTransformationDictionary) Map(java.util.Map) ProcessingDTO(org.kie.pmml.commons.model.ProcessingDTO) KiePMMLFieldRef(org.kie.pmml.commons.model.expressions.KiePMMLFieldRef) MISSING_VALUE_TREATMENT_METHOD(org.kie.pmml.api.enums.MISSING_VALUE_TREATMENT_METHOD) INVALID_VALUE_TREATMENT_METHOD(org.kie.pmml.api.enums.INVALID_VALUE_TREATMENT_METHOD) MINING_FUNCTION(org.kie.pmml.api.enums.MINING_FUNCTION) ParameterInfo(org.kie.api.pmml.ParameterInfo) KiePMMLDefineFunction(org.kie.pmml.commons.transformations.KiePMMLDefineFunction) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) Collectors(java.util.stream.Collectors) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) List(java.util.List) KiePMMLApply(org.kie.pmml.commons.model.expressions.KiePMMLApply) Assert.assertNull(org.junit.Assert.assertNull) PMMLRequestData(org.kie.api.pmml.PMMLRequestData) KiePMMLTestingModel(org.kie.pmml.commons.testingutility.KiePMMLTestingModel) Optional(java.util.Optional) Collections(java.util.Collections) KiePMMLException(org.kie.pmml.api.exceptions.KiePMMLException) Assert.assertEquals(org.junit.Assert.assertEquals) KiePMMLDerivedField(org.kie.pmml.commons.transformations.KiePMMLDerivedField) PMMLRequestData(org.kie.api.pmml.PMMLRequestData) KiePMMLMiningField(org.kie.pmml.commons.model.KiePMMLMiningField) DATA_TYPE(org.kie.pmml.api.enums.DATA_TYPE) Test(org.junit.Test)

Example 62 with PMMLRequestData

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

the class PMMLListenerUtilsTest method stepNotExecuted.

@Test
public void stepNotExecuted() {
    PMMLContext pmmlContext = new PMMLContextImpl(new PMMLRequestData());
    AtomicBoolean invoked = new AtomicBoolean(false);
    PMMLListenerUtils.stepExecuted(() -> new PMMLStepTest(invoked), pmmlContext);
    assertFalse(invoked.get());
}
Also used : PMMLRequestData(org.kie.api.pmml.PMMLRequestData) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl) PMMLContext(org.kie.pmml.api.runtime.PMMLContext) Test(org.junit.Test)

Example 63 with PMMLRequestData

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

the class CategoricalBatchBenchmark method readCSV.

private static PMMLContext readCSV(String line) {
    if (line.startsWith("Age")) {
        return null;
    }
    final String[] split = line.split(",");
    PMMLRequestData pmmlRequestData = new PMMLRequestData("123", MODEL_NAME);
    pmmlRequestData.addRequestParam("Age", Integer.valueOf(split[0]));
    pmmlRequestData.addRequestParam("Employment", split[1]);
    pmmlRequestData.addRequestParam("Education", split[2]);
    pmmlRequestData.addRequestParam("Marital", split[3]);
    pmmlRequestData.addRequestParam("Occupation", split[4]);
    pmmlRequestData.addRequestParam("Income", Double.valueOf(split[5]));
    pmmlRequestData.addRequestParam("Gender", split[6]);
    pmmlRequestData.addRequestParam("Hours", Integer.valueOf(split[8]));
    return new PMMLContextImpl(pmmlRequestData);
}
Also used : PMMLRequestData(org.kie.api.pmml.PMMLRequestData) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl)

Example 64 with PMMLRequestData

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

the class CategoricalBenchmark method setupModel.

@Setup
public void setupModel() throws Exception {
    logger.debug("setup model...");
    modelName = "Sample for logistic regression";
    fileName = "CategoricalRegressionSample.pmml";
    super.setupModel();
    logger.debug("setup pmmlContext...");
    PMMLRequestData pmmlRequestData = new PMMLRequestData("123", modelName);
    pmmlRequestData.addRequestParam("age", 22);
    pmmlRequestData.addRequestParam("work", 3);
    pmmlRequestData.addRequestParam("sex", "0");
    pmmlRequestData.addRequestParam("minority", "1");
    pmmlContext = new PMMLContextImpl(pmmlRequestData);
}
Also used : PMMLRequestData(org.kie.api.pmml.PMMLRequestData) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl) Setup(org.openjdk.jmh.annotations.Setup)

Example 65 with PMMLRequestData

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

the class RegressionBenchmark method setupModel.

@Setup
public void setupModel() throws Exception {
    logger.debug("setup model...");
    modelName = "Sample for linear regression";
    fileName = "LinearRegressionSample.pmml";
    super.setupModel();
    logger.debug("setup pmmlContext...");
    PMMLRequestData pmmlRequestData = new PMMLRequestData("123", modelName);
    pmmlRequestData.addRequestParam("age", 22);
    pmmlRequestData.addRequestParam("salary", 2345.43);
    pmmlRequestData.addRequestParam("car_location", "carpark");
    pmmlContext = new PMMLContextImpl(pmmlRequestData);
}
Also used : PMMLRequestData(org.kie.api.pmml.PMMLRequestData) PMMLContextImpl(org.kie.pmml.evaluator.core.PMMLContextImpl) Setup(org.openjdk.jmh.annotations.Setup)

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