Skip to main content
The Interpretability Extension adds dedicated support for shapiq, along with convenience wrappers for sklearn’s built-in interpretability tools, and for plotting with the shap library (see here). Shapley values explain a single prediction by attributing the prediction’s deviation from the baseline (mean prediction) to individual features. They provide a consistent, game-theoretic measure of feature influence. Mathematically, each Shapley value represents the marginal contribution of a feature across all possible feature combinations. This can be used to:
  • See which features drive model predictions.
  • Compare feature importance across samples.
  • Detect feature interactions.
  • Debug unexpected model behavior.

Why TabPFN is Well-Suited for Interpretability

TabPFN produces smooth, well-calibrated predictions that make post-hoc explanations more stable and meaningful. Because it is a foundation model pretrained on synthetic data, it generalizes without overfitting to individual training samples — so feature attributions reflect genuine patterns. TabPFN follows the scikit-learn estimator API (fit, predict, predict_proba), which means it works out of the box with most interpretability tools in the sklearn ecosystem — partial dependence plots, permutation importance, and any other method that accepts a sklearn-compatible estimator. No wrappers or adapters needed. SHAP beeswarm plot of global feature importance for coronary-disease risk Global feature importance on the heart-statlog dataset: each dot is one patient, horizontal position is the feature’s SHAP value (right = pushed toward disease), colour is the feature value. Blocked vessels and thallium scan dominate, and the clean colour separation shows the model learned monotone, clinically sensible effects. Full walkthrough in the Interpreting Results cookbook.

Installation

This installs shapiq and the other dependencies needed for all methods. To run against the cloud API instead of locally, install tabpfn-client in place of tabpfn:

Quickstart

Train a model, explain a single prediction, and plot the result:
This tutorial runs TabPFN locally, which requires a GPU — see our FAQ for GPU setup. The recommended get_tabpfn_imputation_explainer relies on fit_mode="fit_with_cache", which is local-only and not available in the tabpfn_client backend. To use the cloud API, replace the tabpfn import with tabpfn_client and remove fit_mode (the client does not support it yet).

Choosing a Method

Before diving into each method, here is a summary to help you pick the right tool for the question you are trying to answer.
Two shapiq adaptersget_tabpfn_imputation_explainer uses imputation-based feature removal (marginal / conditional / baseline). The training set is fixed across coalitions, so the KV-cache fast path applies — construct the model with fit_mode="fit_with_cache". This is the recommended adapter. get_tabpfn_explainer uses the remove-and-recontextualize paradigm (Rundel et al. 2024): TabPFN is re-fit for every coalition, so the KV cache cannot be reused — expect this path to be substantially slower.
If you are still unsure which method to use, follow the table below to see the best tools for most common questions.

Use Cases

Explain a prediction with shapiq

Use Shapley interaction indices to understand not just which features matter, but which feature pairs drive a prediction together.
Because TabPFN follows the sklearn API, you can also hand predict_proba to a shap explainer directly and reuse the same values for both the global beeswarm above and per-sample waterfalls (pip install shap):
Waterfall plot for the highest-risk patientWaterfall plot for the lowest-risk patient
Waterfall explanations for the highest-risk (left, 100%) and lowest-risk (right, 1%) patient in the test set. Both start from the same population base rate of 53% and the bars show how each feature moved that patient’s predicted probability. See the Interpreting Results cookbook for the borderline case and the full setup.

Visualize global feature effects with Partial Dependence Plots

PDP and ICE curves show how a feature affects predictions across the whole dataset, not just one sample.
Partial dependence plots for four continuous features Partial dependence for the four most important continuous features of the coronary-disease model. Where SHAP shows attribution, partial dependence shows shape: risk climbs steeply with the number of blocked vessels, falls with maximum heart rate (better exercise capacity is protective), and cholesterol is nearly flat over its observed range.

The remove-and-recontextualize alternative

get_tabpfn_explainer uses the remove-and-recontextualize paradigm (Rundel et al. 2024): TabPFN is re-fit for every coalition, so the KV cache cannot be reused — expect this path to be substantially slower than the recommended get_tabpfn_imputation_explainer. Reach for it when you specifically want this paradigm. It also takes the training labels and does not need fit_mode.

Feature selection

Sequential feature selection identifies the minimal subset of features that contributes most to model performance:

Controlling the budget parameter

The budget parameter in explainer.explain() sets how many coalition samples shapiq evaluates to approximate Shapley values. Each coalition is a subset of features — evaluating more of them produces more accurate estimates but costs more model calls. In theory, exact Shapley values require evaluating all 2^n feature subsets (e.g. 1024 for 10 features, ~1 billion for 30). In practice, shapiq’s approximation algorithms converge well before that: Start low (e.g. budget=128) and increase only if the resulting explanations look noisy or unstable across repeated runs.

Library Reference

interpretability.shapiq.get_tabpfn_imputation_explainer

Creates a shapiq TabularExplainer that uses imputation-based feature removal (marginal / conditional / baseline). The training set is fixed across coalitions, so the KV-cache fast path applies — construct the model with fit_mode="fit_with_cache" (set before .fit()); the wrapper warns at construction time if it is not. This is the recommended adapter. Returns: shapiq.TabularExplainer Call .explain(x, budget=N) where x is a 2D numpy array of shape (1, n_features) and budget is the number of coalition samples to evaluate (see Controlling the budget parameter). Returns a shapiq.InteractionValues object with .plot_waterfall(), .plot_force(), and other visualization methods.

interpretability.shapiq.get_tabpfn_explainer

Creates a shapiq TabPFNExplainer that uses the remove-and-recontextualize paradigm (Rundel et al. 2024). TabPFN is re-fit for every coalition, so the KV cache cannot be reused — expect this path to be substantially slower than the recommended get_tabpfn_imputation_explainer. Returns: shapiq.TabPFNExplainer Same .explain(x, budget=N) interface as above.

interpretability.pdp.partial_dependence_plots

Convenience wrapper around sklearn’s PartialDependenceDisplay.from_estimator. Returns: sklearn.inspection.PartialDependenceDisplay

interpretability.feature_selection.feature_selection

Sequential feature selection using cross-validation. Returns a rich result object with the fitted selector, selected indices/names, and baseline vs. selected CV scores. Returns: FeatureSelectionResult — a dataclass with the following attributes:

interpretability.shap.shapiq_to_shap_explanation

Bridge helper that computes first-order Shapley values with a shapiq explainer and wraps them in a shap.Explanation for use with shap.plots.* and shap.summary_plot. This is the recommended way to use shap plotting with TabPFN (see shap_example.py).
The shap package is not included in the interpretability extra — shapiq handles the computation. Install it separately to use this bridge: pip install shap
Returns: shap.Explanation with values.shape == (n, d). Only first-order Shapley values are wrapped — for higher-order interactions use shapiq’s native plots directly on the InteractionValues object.

FAQ

GPU setup, batch inference, and performance tuning.

Classification

Binary and multi-class classification guide.

Regression

Point estimates, quantiles, and full distributions.

Fine-Tuning

Adapt TabPFN to your domain-specific data.