use of org.kie.kogito.explainability.local.LocalExplanationException in project kogito-apps by kiegroup.
the class LimeExplainer method explainAsync.
@Override
public CompletableFuture<Map<String, Saliency>> explainAsync(Prediction prediction, PredictionProvider model, Consumer<Map<String, Saliency>> intermediateResultsConsumer) {
PredictionInput originalInput = prediction.getInput();
if (originalInput == null || originalInput.getFeatures() == null || (originalInput.getFeatures() != null && originalInput.getFeatures().isEmpty())) {
throw new LocalExplanationException("cannot explain a prediction whose input is empty");
}
List<PredictionInput> linearizedInputs = DataUtils.linearizeInputs(List.of(originalInput));
PredictionInput targetInput = linearizedInputs.get(0);
List<Feature> linearizedTargetInputFeatures = targetInput.getFeatures();
if (linearizedTargetInputFeatures.isEmpty()) {
throw new LocalExplanationException("input features linearization failed");
}
List<Output> actualOutputs = prediction.getOutput().getOutputs();
LimeConfig executionConfig = limeConfig.copy();
return explainWithExecutionConfig(model, originalInput, linearizedTargetInputFeatures, actualOutputs, executionConfig);
}
Aggregations