Search in sources :

Example 6 with DecisionModel

use of org.kie.kogito.decision.DecisionModel in project kogito-apps by kiegroup.

the class LoanEligibilityDmnLimeExplainerTest method getModel.

private PredictionProvider getModel() {
    DMNRuntime dmnRuntime = DMNKogito.createGenericDMNRuntime(new InputStreamReader(getClass().getResourceAsStream("/dmn/LoanEligibility.dmn")));
    assertEquals(1, dmnRuntime.getModels().size());
    final String FRAUD_NS = "https://github.com/kiegroup/kogito-examples/dmn-quarkus-listener-example";
    final String FRAUD_NAME = "LoanEligibility";
    DecisionModel decisionModel = new DmnDecisionModel(dmnRuntime, FRAUD_NS, FRAUD_NAME);
    return new DecisionModelWrapper(decisionModel);
}
Also used : InputStreamReader(java.io.InputStreamReader) DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) DecisionModel(org.kie.kogito.decision.DecisionModel) DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) DMNRuntime(org.kie.dmn.api.core.DMNRuntime)

Example 7 with DecisionModel

use of org.kie.kogito.decision.DecisionModel in project kogito-apps by kiegroup.

the class LoanEligibilityDmnPDPExplainerTest method testLoanEligibilityDMNExplanation.

@Test
void testLoanEligibilityDMNExplanation() throws ExecutionException, InterruptedException, TimeoutException {
    DMNRuntime dmnRuntime = DMNKogito.createGenericDMNRuntime(new InputStreamReader(getClass().getResourceAsStream("/dmn/LoanEligibility.dmn")));
    assertEquals(1, dmnRuntime.getModels().size());
    final String FRAUD_NS = "https://github.com/kiegroup/kogito-examples/dmn-quarkus-listener-example";
    final String FRAUD_NAME = "LoanEligibility";
    DecisionModel decisionModel = new DmnDecisionModel(dmnRuntime, FRAUD_NS, FRAUD_NAME);
    PredictionProvider model = new DecisionModelWrapper(decisionModel);
    List<PredictionInput> inputs = DmnTestUtils.randomLoanEligibilityInputs();
    List<PredictionOutput> predictionOutputs = model.predictAsync(inputs).get(Config.INSTANCE.getAsyncTimeout(), Config.INSTANCE.getAsyncTimeUnit());
    List<Prediction> predictions = new ArrayList<>();
    for (int i = 0; i < predictionOutputs.size(); i++) {
        predictions.add(new SimplePrediction(inputs.get(i), predictionOutputs.get(i)));
    }
    PartialDependencePlotExplainer partialDependencePlotExplainer = new PartialDependencePlotExplainer();
    List<PartialDependenceGraph> pdps = partialDependencePlotExplainer.explainFromPredictions(model, predictions);
    assertThat(pdps).isNotNull();
    Assertions.assertThat(pdps).hasSize(20);
}
Also used : SimplePrediction(org.kie.kogito.explainability.model.SimplePrediction) InputStreamReader(java.io.InputStreamReader) PredictionInput(org.kie.kogito.explainability.model.PredictionInput) SimplePrediction(org.kie.kogito.explainability.model.SimplePrediction) Prediction(org.kie.kogito.explainability.model.Prediction) ArrayList(java.util.ArrayList) DecisionModel(org.kie.kogito.decision.DecisionModel) DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) PredictionProvider(org.kie.kogito.explainability.model.PredictionProvider) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) PartialDependencePlotExplainer(org.kie.kogito.explainability.global.pdp.PartialDependencePlotExplainer) PredictionOutput(org.kie.kogito.explainability.model.PredictionOutput) DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) PartialDependenceGraph(org.kie.kogito.explainability.model.PartialDependenceGraph) Test(org.junit.jupiter.api.Test)

Example 8 with DecisionModel

use of org.kie.kogito.decision.DecisionModel in project kogito-apps by kiegroup.

the class PrequalificationDmnLimeExplainerTest method getModel.

private PredictionProvider getModel() {
    DMNRuntime dmnRuntime = DMNKogito.createGenericDMNRuntime(new InputStreamReader(getClass().getResourceAsStream("/dmn/Prequalification-1.dmn")));
    assertEquals(1, dmnRuntime.getModels().size());
    final String NS = "http://www.trisotech.com/definitions/_f31e1f8e-d4ce-4a3a-ac3b-747efa6b3401";
    final String NAME = "Prequalification";
    DecisionModel decisionModel = new DmnDecisionModel(dmnRuntime, NS, NAME);
    return new DecisionModelWrapper(decisionModel);
}
Also used : InputStreamReader(java.io.InputStreamReader) DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) DecisionModel(org.kie.kogito.decision.DecisionModel) DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) DMNRuntime(org.kie.dmn.api.core.DMNRuntime)

Example 9 with DecisionModel

use of org.kie.kogito.decision.DecisionModel in project kogito-apps by kiegroup.

the class ComplexEligibilityDmnCounterfactualExplainerTest method getModel.

private PredictionProvider getModel() {
    DMNRuntime dmnRuntime = DMNKogito.createGenericDMNRuntime(new InputStreamReader(getClass().getResourceAsStream("/dmn/ComplexEligibility.dmn")));
    assertEquals(1, dmnRuntime.getModels().size());
    final String COMPLEX_ELIGIBILITY_NS = "https://kiegroup.org/dmn/_B305FE71-3B8C-48C5-B5B1-D9CC04825B16";
    final String COMPLEX_ELIGIBILITY_NAME = "myComplexEligibility";
    DecisionModel decisionModel = new DmnDecisionModel(dmnRuntime, COMPLEX_ELIGIBILITY_NS, COMPLEX_ELIGIBILITY_NAME);
    return new DecisionModelWrapper(decisionModel, List.of());
}
Also used : InputStreamReader(java.io.InputStreamReader) DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) DecisionModel(org.kie.kogito.decision.DecisionModel) DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) DMNRuntime(org.kie.dmn.api.core.DMNRuntime)

Example 10 with DecisionModel

use of org.kie.kogito.decision.DecisionModel in project kogito-runtimes by kiegroup.

the class BaseSpringBootDecisionTracingTest method testSyncListenerAndCollectorWithRealEventsIsWorking.

@Test
void testSyncListenerAndCollectorWithRealEventsIsWorking() throws IOException {
    final DMNRuntime runtime = buildDMNRuntime();
    final DecisionModel model = buildDecisionModel(runtime);
    final List<EvaluateEvent> events = testListener(false, runtime, model);
    testCollector(events, model);
}
Also used : DecisionModel(org.kie.kogito.decision.DecisionModel) DmnDecisionModel(org.kie.kogito.dmn.DmnDecisionModel) DMNRuntime(org.kie.dmn.api.core.DMNRuntime) EvaluateEvent(org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent) Test(org.junit.jupiter.api.Test)

Aggregations

DecisionModel (org.kie.kogito.decision.DecisionModel)28 DMNRuntime (org.kie.dmn.api.core.DMNRuntime)22 DmnDecisionModel (org.kie.kogito.dmn.DmnDecisionModel)22 InputStreamReader (java.io.InputStreamReader)15 Test (org.junit.jupiter.api.Test)14 ArrayList (java.util.ArrayList)7 Prediction (org.kie.kogito.explainability.model.Prediction)7 PredictionInput (org.kie.kogito.explainability.model.PredictionInput)7 PredictionOutput (org.kie.kogito.explainability.model.PredictionOutput)7 PredictionProvider (org.kie.kogito.explainability.model.PredictionProvider)7 SimplePrediction (org.kie.kogito.explainability.model.SimplePrediction)7 DMNContext (org.kie.dmn.api.core.DMNContext)6 EvaluateEvent (org.kie.kogito.tracing.decision.event.evaluate.EvaluateEvent)6 HashMap (java.util.HashMap)5 DMNResult (org.kie.dmn.api.core.DMNResult)5 PartialDependencePlotExplainer (org.kie.kogito.explainability.global.pdp.PartialDependencePlotExplainer)4 PartialDependenceGraph (org.kie.kogito.explainability.model.PartialDependenceGraph)4 Random (java.util.Random)3 LimeConfig (org.kie.kogito.explainability.local.lime.LimeConfig)3 LimeExplainer (org.kie.kogito.explainability.local.lime.LimeExplainer)3