When to use FPDE
Use FPDE when you have:- A feature matrix where each column has a consistent meaning.
- Class labels for training samples.
- A classification model, usually one that exposes
predict_proba. - A need to explain target-versus-rival evidence at the feature level.
Core terms
| Term | Meaning |
|---|---|
| Prototype | A representative feature vector for a class. FPDE currently builds one class-mean prototype per class. |
| Target class | The class being explained, often the classifier’s predicted class. |
| Rival class | The contrast class, often the second-highest-probability class. |
| Evidence | The scalar target-versus-rival contrast decomposed by FPDE. |
| Attribution | A per-feature contribution to the evidence value. |
| Anchor | A reference vector used by Cos-FPDE before computing cosine contrasts. |
| Baseline | A replacement vector used for deletion and insertion perturbation curves. |
Prototype construction
class_mean_prototypes(X, y) computes one prototype per class by averaging all training rows with that class label.
FPDEEngine.fit(X_train, y_train, model) builds the same prototype state and stores it for repeated explanations.
For repeated workflows, prefer FPDEEngine because it reuses:
- Class-mean prototypes
- Prototype labels
- Mean and zero anchors
- The baseline vector
- Label-to-prototype lookup state
Target and rival selection
When you useFPDEEngine with a model, FPDE chooses the local contrast from predict_proba.
When you call lower-level functions directly, pass
positive_label and negative_label.
If you omit negative_label, FPDE selects a non-target prototype according to the selected mode.
Diff-FPDE
Diff-FPDE decomposes the difference in squared distances from the input to the rival and target prototypes.Cos-FPDE
Cos-FPDE decomposes a regularized cosine-similarity contrast.Hyb-FPDE
Hyb-FPDE mixes Diff-FPDE and Cos-FPDE attribution vectors.lambda_hyb must be in [0, 1].
lambda_hyb=1.0uses the Diff-FPDE endpoint.lambda_hyb=0.0uses the Cos-FPDE endpoint.- Intermediate values blend both attribution vectors.
normalize="none" when you want to mix the raw component scales.
Interpreting results
An FPDE explanation contains:attributions: one contribution per featureevidence: the sum of the attribution vector for the selected contrastpositive_scoreandnegative_score: the target and rival side scoresexactness_residual: numerical difference between summed attribution and direct evidence- Prototype labels and prototype indices
FPDEExplanation.normalized_attributions returns an L1-normalized attribution vector.
Use it for plotting, not as the raw evidence scale.