use of org.kie.kogito.explainability.api.LIMEExplainabilityRequest in project kogito-apps by kiegroup.
the class LimeExplainerServiceHandlerTest method testGetPredictionWithEmptyDefinition.
@Test
public void testGetPredictionWithEmptyDefinition() {
LIMEExplainabilityRequest request = new LIMEExplainabilityRequest(EXECUTION_ID, SERVICE_URL, MODEL_IDENTIFIER, Collections.emptyList(), Collections.emptyList());
Prediction prediction = handler.getPrediction(request);
assertTrue(prediction instanceof SimplePrediction);
SimplePrediction simplePrediction = (SimplePrediction) prediction;
assertTrue(simplePrediction.getInput().getFeatures().isEmpty());
assertTrue(simplePrediction.getOutput().getOutputs().isEmpty());
}
use of org.kie.kogito.explainability.api.LIMEExplainabilityRequest in project kogito-apps by kiegroup.
the class LocalExplainerServiceHandlerRegistryTest method testLIME_explainAsyncWithResults.
@Test
public void testLIME_explainAsyncWithResults() {
LIMEExplainabilityRequest request = new LIMEExplainabilityRequest(EXECUTION_ID, SERVICE_URL, MODEL_IDENTIFIER, Collections.emptyList(), Collections.emptyList());
registry.explainAsyncWithResults(request, callback);
verify(limeExplainerServiceHandler).explainAsyncWithResults(eq(request), eq(callback));
}
use of org.kie.kogito.explainability.api.LIMEExplainabilityRequest in project kogito-apps by kiegroup.
the class ExplainabilityApiV1IT method testEndpointWithRequest.
@Test
void testEndpointWithRequest() throws JsonProcessingException {
ModelIdentifier modelIdentifier = new ModelIdentifier("dmn", "namespace:name");
String body = MAPPER.writeValueAsString(new LIMEExplainabilityRequest(executionId, serviceUrl, modelIdentifier, Collections.emptyList(), Collections.emptyList()));
BaseExplainabilityResult result = given().contentType(ContentType.JSON).body(body).when().post("/v1/explain").as(BaseExplainabilityResult.class);
assertEquals(executionId, result.getExecutionId());
}
use of org.kie.kogito.explainability.api.LIMEExplainabilityRequest in project kogito-apps by kiegroup.
the class TrustyServiceImpl method processDecision.
@Override
public void processDecision(String executionId, Decision decision) {
storeDecision(executionId, decision);
if (isExplainabilityEnabled) {
List<NamedTypedValue> inputs = decision.getInputs() != null ? decision.getInputs().stream().map(input -> new NamedTypedValue(input.getName(), input.getValue())).collect(Collectors.toList()) : Collections.emptyList();
List<NamedTypedValue> outputs = decision.getOutcomes() != null ? decision.getOutcomes().stream().map(output -> new NamedTypedValue(output.getOutcomeName(), output.getOutcomeResult())).collect(Collectors.toList()) : Collections.emptyList();
explainabilityRequestProducer.sendEvent(new LIMEExplainabilityRequest(executionId, decision.getServiceUrl(), createDecisionModelIdentifier(decision), inputs, outputs));
}
}
use of org.kie.kogito.explainability.api.LIMEExplainabilityRequest in project kogito-apps by kiegroup.
the class ExplainabilityRequestProducerTest method test.
@Test
void test() {
AssertSubscriber<String> subscriber = AssertSubscriber.create(1);
ExplainabilityRequestProducer producer = new ExplainabilityRequestProducer();
producer.getEventPublisher().subscribe(subscriber);
producer.sendEvent(new LIMEExplainabilityRequest("executionId", "http://localhost:8080/model", new ModelIdentifier("dmn", "modelNamespace:model"), Collections.emptyList(), Collections.emptyList()));
assertEquals(1, subscriber.getItems().size());
}
Aggregations