use of org.kie.pmml.evaluator.core.PMMLContextImpl 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);
}
use of org.kie.pmml.evaluator.core.PMMLContextImpl 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);
}
use of org.kie.pmml.evaluator.core.PMMLContextImpl 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);
}
use of org.kie.pmml.evaluator.core.PMMLContextImpl 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);
});
}
use of org.kie.pmml.evaluator.core.PMMLContextImpl 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);
}
Aggregations