use of org.kie.kogito.dmn.DmnDecisionModel 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);
}
use of org.kie.kogito.dmn.DmnDecisionModel 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);
}
use of org.kie.kogito.dmn.DmnDecisionModel 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);
}
use of org.kie.kogito.dmn.DmnDecisionModel 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());
}
use of org.kie.kogito.dmn.DmnDecisionModel in project kogito-runtimes by kiegroup.
the class DecisionExplainabilityResourceExecutorTest method testGetDecisionModel.
@ParameterizedTest
@MethodSource("getDecisionModelTestProvider")
public void testGetDecisionModel(String[] args) {
String namespace = args[0];
String name = args[1];
DecisionExplainabilityResourceExecutor executor = new DecisionExplainabilityResourceExecutor();
DecisionModels decisionModels = mock(DecisionModels.class);
DecisionModel model = new DmnDecisionModel(generateDMNRuntime(namespace, name), namespace, name);
when(decisionModels.getDecisionModel(eq(namespace), eq(name))).thenReturn(model);
ModelIdentifier modelIdentifier = new ModelIdentifier("dmn", String.format("%s%s%s", namespace, RESOURCE_ID_SEPARATOR, name));
DecisionModel decisionModelResponse = executor.getDecisionModel(decisionModels, modelIdentifier);
Assertions.assertNotNull(decisionModelResponse);
Assertions.assertEquals(namespace, decisionModelResponse.getDMNModel().getNamespace());
Assertions.assertEquals(name, decisionModelResponse.getDMNModel().getName());
}
Aggregations