Skip to main content
Feature Prototype Direction Explainer (FPDE) is a Python package for prototype-contrast feature attribution. It explains a classification result by comparing an input with a prototype for the target class and a prototype for a rival class. FPDE then decomposes that contrast into one contribution per feature. Use FPDE when you need a lightweight, post-hoc explanation method for tabular-style feature vectors and black-box classifiers that expose class probabilities.

What you can do

  • Build class-mean prototypes from training data.
  • Explain one sample with Diff-FPDE, Cos-FPDE, or Hyb-FPDE.
  • Explain batches while reusing fitted prototype state.
  • Search Diff, Cos, and Hyb-FPDE candidate settings.
  • Select lambda_hyb with held-out deletion and insertion validation.
  • Compute deletion and insertion perturbation curves for an attribution vector.
  • Plot attribution bars, cumulative waterfalls, contribution summaries, attribution heatmaps, prototype similarity distributions, and perturbation curves.

How FPDE explains a prediction

FPDE starts from a local class contrast. The target class is usually the classifier’s top predicted class. The rival class is usually the second-highest-probability class. FPDE compares the input against the target prototype and the rival prototype. Positive attribution values support the target class relative to the rival class. Negative values support the rival class relative to the target class.

Quickstart

Install FPDE, fit an engine, and explain your first sample.

Method overview

Learn the target-versus-rival contrast behind Diff-FPDE, Cos-FPDE, and Hyb-FPDE.

API reference

Review the public functions, classes, parameters, and result objects.

Reproducibility

Record the settings you need to reproduce FPDE experiments.

Requirements

FPDE requires Python 3.12 or newer. The package depends on NumPy and scikit-learn.
python -m pip install fpde
To use the plotting helpers, install the optional plot extra, which adds matplotlib:
python -m pip install "fpde[plot]"