FPDEEngine for most workflows.
It stores prototypes, anchors, the baseline vector, and label lookup state so you can reuse them across explanations.
Explain one sample
details["target_label"] is the model’s highest-probability class.
details["rival_label"] is the second-highest-probability class.
Explain a batch
Useexplain_batch when you need both attribution rows and per-sample metadata.
explain_matrix when you only need the attribution matrix.
Select lambda_hyb
Use held-out validation data to select a fixed Hyb-FPDE mixture.
The selection score combines deletion and insertion perturbation curves.
selection.rows with your experiment results so you can inspect the score for each candidate later.
Run grid search
Usegrid_search to compare Diff-FPDE, Cos-FPDE, and Hyb-FPDE candidate settings.
Direct prototype functions
Use lower-level functions when you want direct control over prototypes and labels.FPDEEngine.
Visualize explanations
The plotting helpers exported fromfpde and the compact fpde.plots namespace render FPDE attributions, prototype similarities, and perturbation curves with matplotlib.
Install the optional plot extra first:
Axes you can save or arrange in a subplot.
Local attribution bar and waterfall
Useplot_attributions for a signed bar chart of one explanation, and plot_attribution_waterfall for a cumulative view.
Batch summary with beeswarm
Use fpde.plots.beeswarm to summarize per-sample contributions across a batch, colored by feature value.
Prototype similarity distribution
Useplot_prototype_similarity_distribution to see how the explained sample sits between the target and rival prototypes.
Attribution heatmap for image features
When features form an image, reshape the attribution vector withplot_attribution_image.
Perturbation curves
After computing deletion and insertion curves, visualize them withplot_perturbation_curves.
Full notebook
For an end-to-end walkthrough covering bar, waterfall, beeswarm, similarity, image, and perturbation plots on the breast cancer dataset, seeexamples/plot_fpde_example.ipynb in the FPDE repository.