Search in sources :

Example 1 with LocalExplanationException

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);
}
Also used : PredictionInput(org.kie.kogito.explainability.model.PredictionInput) PredictionOutput(org.kie.kogito.explainability.model.PredictionOutput) Output(org.kie.kogito.explainability.model.Output) LocalExplanationException(org.kie.kogito.explainability.local.LocalExplanationException) Feature(org.kie.kogito.explainability.model.Feature)

Aggregations

LocalExplanationException (org.kie.kogito.explainability.local.LocalExplanationException)1 Feature (org.kie.kogito.explainability.model.Feature)1 Output (org.kie.kogito.explainability.model.Output)1 PredictionInput (org.kie.kogito.explainability.model.PredictionInput)1 PredictionOutput (org.kie.kogito.explainability.model.PredictionOutput)1