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 feature vectors and classifiers that expose class probabilities.

Install FPDE

Install the PyPI package and check that your environment meets the requirements.

Run the quickstart

Train a scikit-learn classifier and explain your first sample.

Explain one sample

Fit reusable prototype state and inspect a single target-versus-rival explanation.

Explain batches

Generate attribution matrices while keeping per-sample metadata.

Choose lambda_hyb

Select a Hyb-FPDE mixture weight with held-out deletion and insertion validation.

Look up APIs

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

What FPDE does

FPDE builds one class-mean prototype per class from training data. For one input, it chooses a target class and a rival class. With FPDEEngine, the target class is the model’s highest-probability class and the rival class is the second-highest-probability class. The output is an attribution vector with one value per feature. Positive values support the target class. Negative values support the rival class.

What you need

  • Python 3.12 or newer
  • NumPy and scikit-learn
  • Training data and labels in the same feature space used by the classifier
  • A fitted classifier with predict_proba and classes_ for model-driven workflows
Start with the quickstart if you are new to FPDE. Use the method overview when you need the details behind Diff-FPDE, Cos-FPDE, and Hyb-FPDE.