FPDEEngine.select_lambda to choose a fixed lambda_hyb before you explain final evaluation or test samples.
The method evaluates candidates with deletion and insertion perturbation curves on held-out data.
Prerequisites
- A fitted
FPDEEngine - Held-out validation samples
X_val - A classifier with
predict_probaandclasses_ - A candidate grid for
lambda_hyb
Run selection
1
Choose a candidate grid
Start with a small grid.
2
Evaluate validation samples
Score each candidate on held-out samples.
3
Reuse the selected value
Explain final samples with the selected
lambda_hyb.Inspect the result
selection.rows contains the candidate scores.
Save it with your experiment artifacts.
How selection is scored
For each candidate, FPDE computes deletion and insertion curves. Deletion replaces top-ranked features with the baseline. Insertion starts from the baseline and restores top-ranked features. The combined score is:Bayesian selection
UseFPDEEngine.select_bayesian_lambda when you want a posterior over lambda_hyb candidates instead of a single fixed value.
The method scores each unique candidate with the same deletion and insertion validation as select_lambda, combines the scores with a Beta prior, and normalizes the result into a finite-grid posterior.
The posterior is limited to the lambda_hyb grid.
It does not sample class prototypes, estimate feature-level prototype uncertainty, or model classifier uncertainty.
Build the posterior
alphaandbetaset the Beta prior overlambda_hyb. The defaultsalpha=1.0, beta=1.0give a uniform prior.temperaturescales how sharply validation scores concentrate posterior mass. Lower values produce a more peaked posterior.credible_masssets the coverage of the reported credible interval. The default is0.95.
Inspect the posterior
selection.posterior_rows holds the posterior mass and validation score for each candidate.
The credible interval is an interval over lambda_hyb candidates, not a per-feature attribution interval.
Explain with the posterior mean
Pass the selection result toexplain_one_bayesian or explain_batch_bayesian.
Both use selection.posterior_mean_lambda and reuse the normalize, anchor_strategy, and eps values from selection.
details["posterior_mean_lambda"] records the lambda that produced the attributions.
For a runnable end-to-end walkthrough, including posterior plots and credible-interval attribution ranges, see examples/bayesian_fpde_example.ipynb.