use of org.kie.pmml.pmml_4_2.PMMLExecutor in project drools by kiegroup.
the class ScorecardTest method testScorecardWithCompoundPredicate.
@Test
public void testScorecardWithCompoundPredicate() {
KieBase kieBase = PMMLKieBaseUtil.createKieBaseWithPMML(SOURCE_COMPOUND_PREDICATE_SCORECARD);
PMMLExecutor executor = new PMMLExecutor(kieBase);
PMMLRequestData requestData = new PMMLRequestData("123", "ScorecardCompoundPredicate");
requestData.addRequestParam("param1", 41.0);
requestData.addRequestParam("param2", 21.0);
PMML4Result resultHolder = executor.run(requestData);
double score = resultHolder.getResultValue("ScoreCard", "score", Double.class).get();
Assertions.assertThat(score).isEqualTo(120.8);
Map<String, Double> rankingMap = (Map<String, Double>) resultHolder.getResultValue("ScoreCard", "ranking");
Assertions.assertThat(rankingMap.get("reasonCh1")).isEqualTo(50);
Assertions.assertThat(rankingMap.get("reasonCh2")).isEqualTo(5);
requestData = new PMMLRequestData("123", "ScorecardCompoundPredicate");
requestData.addRequestParam("param1", 40.0);
requestData.addRequestParam("param2", 25.0);
resultHolder = executor.run(requestData);
score = resultHolder.getResultValue("ScoreCard", "score", Double.class).get();
Assertions.assertThat(score).isEqualTo(120.8);
requestData = new PMMLRequestData("123", "ScorecardCompoundPredicate");
requestData.addRequestParam("param1", 40.0);
requestData.addRequestParam("param2", 55.0);
resultHolder = executor.run(requestData);
score = resultHolder.getResultValue("ScoreCard", "score", Double.class).get();
Assertions.assertThat(score).isEqualTo(210.8);
requestData = new PMMLRequestData("123", "ScorecardCompoundPredicate");
requestData.addRequestParam("param1", 4.0);
requestData.addRequestParam("param2", -25.0);
resultHolder = executor.run(requestData);
score = resultHolder.getResultValue("ScoreCard", "score", Double.class).get();
Assertions.assertThat(score).isEqualTo(30.8);
}
Aggregations