peal.explainers.interfaces.ExplainerInterface

class peal.explainers.interfaces.ExplainerInterface[source]

Bases: ABC

Duck-typed interface every explainer implements.

Subclasses hold their config in explainer_config and must override explain_batch; the remaining methods are no-op defaults that explainers without an interactive feedback loop may leave untouched.

Methods

explain_batch

Explain one batch of samples.

human_annotate_explanations

Collect human feedback for previously created explanations (no-op).

run

Run the explainer stand-alone (outside of an adaptor).

visualize_interpretations

Visualize interpreted explanations together with their feedback (no-op).

Attributes

explainer_config: ExplainerConfig
abstract explain_batch(batch, **args)[source]

Explain one batch of samples.

Parameters:
  • batch (sequence) – A dataset batch, typically (x, y, ...) tensors.

  • **args – Explainer-specific keyword arguments.

Raises:

NotImplementedError – Always, in the base class.

run(oracle_path=None, confounder_oracle_path=None)[source]

Run the explainer stand-alone (outside of an adaptor).

Parameters:
  • oracle_path (str, optional) – Path of an oracle classifier used to evaluate the explanations.

  • confounder_oracle_path (str, optional) – Path of a confounder oracle used to evaluate the explanations.

human_annotate_explanations(param)[source]

Collect human feedback for previously created explanations (no-op).

visualize_interpretations(feedback, param, param1)[source]

Visualize interpreted explanations together with their feedback (no-op).