use of org.kie.pmml.pmml_4_2.PMMLExecutor in project drools by kiegroup.
the class DecisionTreeTest method testWeightedConfidenceMissingValueStrategy.
@Test
public // @Ignore
void testWeightedConfidenceMissingValueStrategy() {
KieBase kieBase = PMMLKieBaseUtil.createKieBaseWithPMML(TREE_WEIGHTED_CONFIDENCE_MISSING_STRATEGY);
PMMLExecutor executor = new PMMLExecutor(kieBase);
PMMLRequestData request = new PMMLRequestData("123", "TreeTest");
request.addRequestParam("fld1", 30.0);
PMML4Result resultHolder = executor.run(request);
Assertions.assertThat(resultHolder).isNotNull();
Assertions.assertThat(resultHolder.getResultValue("Fld3", "value", String.class).get()).isEqualTo("tgtY");
executor.setRunWithLogging(true);
request = new PMMLRequestData("123", "TreeTest");
request.addRequestParam("fld1", 50.0);
resultHolder = executor.run(request);
Assertions.assertThat(resultHolder).isNotNull();
Assertions.assertThat(resultHolder.getResultValue("Fld3", "value", String.class).get()).isEqualTo("tgtX");
}
use of org.kie.pmml.pmml_4_2.PMMLExecutor in project drools by kiegroup.
the class DecisionTreeTest method testReturnLastNoTrueChildPredictionStrategy.
@Test
public void testReturnLastNoTrueChildPredictionStrategy() {
KieBase kieBase = PMMLKieBaseUtil.createKieBaseWithPMML(TREE_RETURN_LAST_NOTRUE_CHILD_STRATEGY);
PMMLExecutor executor = new PMMLExecutor(kieBase);
PMMLRequestData request = new PMMLRequestData("123", "TreeTest");
request.addRequestParam("fld1", 30.0);
PMML4Result resultHolder = executor.run(request);
Assertions.assertThat(resultHolder).isNotNull();
String targetValue = resultHolder.getResultValue("Fld2", "value", String.class).orElse(null);
Assertions.assertThat(targetValue).isEqualTo("tgtY");
request = new PMMLRequestData("123", "TreeTest");
request.addRequestParam("fld1", 50.0);
resultHolder = executor.run(request);
Assertions.assertThat(resultHolder).isNotNull();
targetValue = resultHolder.getResultValue("Fld2", "value", String.class).orElse(null);
Assertions.assertThat(targetValue).isEqualTo("tgtX");
}
use of org.kie.pmml.pmml_4_2.PMMLExecutor in project drools by kiegroup.
the class DecisionTreeTest method testDefaultChildMissingValueStrategy.
@Test
public void testDefaultChildMissingValueStrategy() {
KieBase kieBase = PMMLKieBaseUtil.createKieBaseWithPMML(TREE_DEFAULT_CHILD_MISSING_STRATEGY);
PMMLExecutor executor = new PMMLExecutor(kieBase);
PMMLRequestData request = new PMMLRequestData("123", "TreeTest");
request.addRequestParam("fld1", 30.0);
PMML4Result resultHolder = executor.run(request);
Assertions.assertThat(resultHolder).isNotNull();
Assertions.assertThat(resultHolder.getResultValue("Fld3", "value", String.class).get()).isEqualTo("tgtY");
request = new PMMLRequestData("123", "TreeTest");
request.addRequestParam("fld1", 100.0);
resultHolder = executor.run(request);
Assertions.assertThat(resultHolder).isNotNull();
Assertions.assertThat(resultHolder.getResultValue("Fld3", "value", String.class).get()).isEqualTo("tgtZ");
}
use of org.kie.pmml.pmml_4_2.PMMLExecutor in project drools by kiegroup.
the class ScorecardTest method testScorecardWithSimpleSetPredicateWithSpaceValue.
@Test
public void testScorecardWithSimpleSetPredicateWithSpaceValue() {
KieBase kieBase = PMMLKieBaseUtil.createKieBaseWithPMML(SOURCE_SIMPLE_SET_SPACE_VALUE_SCORECARD);
PMMLExecutor executor = new PMMLExecutor(kieBase);
PMMLRequestData requestData = new PMMLRequestData("123", "SimpleSetScorecardWithSpaceValue");
requestData.addRequestParam("param", "optA");
PMML4Result resultHolder = executor.run(requestData);
Assertions.assertThat(resultHolder).isNotNull();
double score = resultHolder.getResultValue("ScoreCard", "score", Double.class).get();
Assertions.assertThat(score).isEqualTo(13);
}
use of org.kie.pmml.pmml_4_2.PMMLExecutor in project drools by kiegroup.
the class ScorecardTest method testScorecardWithSimpleSetPredicate.
@Test
public void testScorecardWithSimpleSetPredicate() {
KieBase kieBase = PMMLKieBaseUtil.createKieBaseWithPMML(SOURCE_SIMPLE_SET_SCORECARD);
PMMLExecutor executor = new PMMLExecutor(kieBase);
PMMLRequestData requestData = new PMMLRequestData("123", "SimpleSetScorecard");
requestData.addRequestParam("param1", 4);
requestData.addRequestParam("param2", "optA");
PMML4Result resultHolder = executor.run(requestData);
Assertions.assertThat(resultHolder).isNotNull();
double score = resultHolder.getResultValue("ScoreCard", "score", Double.class).get();
Assertions.assertThat(score).isEqualTo(113);
requestData = new PMMLRequestData("123", "SimpleSetScorecard");
requestData.addRequestParam("param1", 5);
requestData.addRequestParam("param2", "optA");
resultHolder = executor.run(requestData);
Assertions.assertThat(resultHolder).isNotNull();
score = resultHolder.getResultValue("ScoreCard", "score", Double.class).get();
Assertions.assertThat(score).isEqualTo(33);
requestData = new PMMLRequestData("123", "SimpleSetScorecard");
requestData.addRequestParam("param1", -5);
requestData.addRequestParam("param2", "optC");
resultHolder = executor.run(requestData);
Assertions.assertThat(resultHolder).isNotNull();
score = resultHolder.getResultValue("ScoreCard", "score", Double.class).get();
Assertions.assertThat(score).isEqualTo(123);
requestData = new PMMLRequestData("123", "SimpleSetScorecard");
requestData.addRequestParam("param1", -5);
requestData.addRequestParam("param2", "optA");
resultHolder = executor.run(requestData);
Assertions.assertThat(resultHolder).isNotNull();
score = resultHolder.getResultValue("ScoreCard", "score", Double.class).get();
Assertions.assertThat(score).isEqualTo(113);
}
Aggregations