Interface LocalExplainerServiceHandler<T,R extends BaseExplainabilityRequest>

Type Parameters:
T - the type of local explanation generated
R - the type of the local explanation request
All Superinterfaces:
org.kie.kogito.explainability.local.LocalExplainer<T>
All Known Implementing Classes:
CounterfactualExplainerServiceHandler, LimeExplainerServiceHandler

public interface LocalExplainerServiceHandler<T,R extends BaseExplainabilityRequest> extends org.kie.kogito.explainability.local.LocalExplainer<T>
A local explainability handler that delegates explanation to a LocalExplainer and handles assembly of the BaseExplainabilityResult for both success and failure states of explanation calculation.
  • Method Details

    • supports

      <U extends BaseExplainabilityRequest> boolean supports(Class<U> type)
      Checks whether an implementation supports a type of explanation.
      Parameters:
      type - The Trusty Service request type.
      Returns:
      true if the implementation supports the type of explanation.
    • getPrediction

      org.kie.kogito.explainability.model.Prediction getPrediction(R request)
      Gets a Prediction object from the request for the LocalExplainer. It should contain all the necessary information for the LocalExplainer to calculate an explanation.
      Parameters:
      request - The explanation request.
      Returns:
      A Prediction object containing all of the information necessary to calculate an explanation.
    • getPredictionProvider

      org.kie.kogito.explainability.model.PredictionProvider getPredictionProvider(R request)
      Gets a PredictionProvider object from the request for the LocalExplainer.
      Parameters:
      request - The explanation request.
      Returns:
      A PredictionProvider object.
    • explainAsyncWithResults

      default CompletableFuture<BaseExplainabilityResult> explainAsyncWithResults(R request, Consumer<BaseExplainabilityResult> intermediateResultsConsumer)
      Requests calculation of an explanation decorated with both "success" and "failure" result handlers. See: - LocalExplainer.explainAsync(org.kie.kogito.explainability.model.Prediction, org.kie.kogito.explainability.model.PredictionProvider) - createSucceededResult(BaseExplainabilityRequest, Object) - createFailedResult(BaseExplainabilityRequest, Throwable)
      Parameters:
      request - The explanation request.
      intermediateResultsConsumer - A consumer for intermediate results provided by the explainer.
      Returns:
    • createSucceededResult

      BaseExplainabilityResult createSucceededResult(R request, T result)
      Creates a result containing the "success" information for an explanation calculation.
      Parameters:
      request - The original request.
      result - The result from the LocalExplainer calculation.
      Returns:
    • createFailedResult

      BaseExplainabilityResult createFailedResult(R request, Throwable throwable)
      Creates a result containing the "failed" information for an explanation calculation.
      Parameters:
      request - The original request.
      throwable - The exception thrown during calculation.
      Returns:
    • createIntermediateResult

      BaseExplainabilityResult createIntermediateResult(R request, T result)
      Creates a result containing the "intermediate" information for an explanation calculation.
      Parameters:
      request - The original request.
      result - The intermediate result from the LocalExplainer calculation.
      Returns: