Skip to content

Replace algorithm-name string branches in default invokers with declarative registry-spec fields #324

Description

@stanlrt

From /simplify codebase sweep (2026-06-10).

The adapters' DEFAULT invoke paths carry inline algorithm-name special cases, although the per-entry invoker field (#266) and per-entry ExplainerAlgorithmSpec hints are the project's canonical seam for exactly this non-uniformity:

  • transparency/explainers/captum_explainer.py:251-257: if explainer.algorithm == "Occlusion"
  • transparency/explainers/captum_explainer.py:266-273: algorithm.startswith("Layer") or algorithm == "GuidedGradCam" -- excludes Neuron* by comment, not by data; the prefix check drifts as Captum adds methods
  • transparency/explainers/shap_explainer.py:349,358,385: three independent algorithm-name tuples branching background-requirement, numpy-wrapping, and tensor-vs-numpy input format -- must stay mutually consistent by hand; adding e.g. PermutationExplainer means auditing all three branches

Each special case in the shared path makes the default invoker less default.

Fix: declarative spec fields per registry entry (takes_layer: bool, requires_background: bool, input_format: tensor|numpy, kwarg_normaliser), or a per-entry invoker for the genuinely divergent ones (Occlusion, KernelExplainer). The startswith("Layer") check is data masquerading as code. Related deferred outliers: #276, #277, #278, #279, #280.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions