Skip to main content
ByPrior Labs
With SHAP values and partial dependence plots. A strong classifier is only useful in practice if you can explain what it is doing. TabPFN works with the standard interpretability toolkit, so the same SHAP and partial-dependence techniques you would use on any model apply directly. Working with a coronary-disease dataset, this notebook covers global feature importance, how predictions respond to each feature, and how to explain individual patient predictions.

Setup

Installing TabPFN, its interpretability extensions, and SHAP. tabpfn_extensions provides the interpretability helpers used here; shap provides the explainer and plots.

Loading the Data

A coronary-disease dataset, relabelled for readable explanations. We use the heart-statlog dataset. Interpretability is only as clear as the feature names, so we rename the columns to plain language and keep a decoding map for categorical values. This makes every plot below far easier to read.

Readable names and categories

Mapping column names and codes to human-readable labels.

Fit and Predict

Training the classifier we are going to explain. We fit TabPFNClassifier, passing the categorical feature indices so the model treats them correctly, and keep the predicted probabilities for the test set.

Global Feature Importance

SHAP values across the whole test set. A permutation SHAP explainer attributes each prediction to its features. The beeswarm plot summarises every patient at once: horizontal position shows whether a feature pushed risk up or down, colour shows whether the feature value was high or low.
Global Feature Importance

Partial Dependence

How average predicted risk moves with each measurement. Where SHAP shows attribution, partial dependence shows shape. For the top continuous features we trace how the average predicted probability changes as we sweep each one across its range.
Partial Dependence

Explaining Individual Predictions

Waterfall explanations for specific patients. Global views aside, clinicians reason about individuals. Starting from the population base rate, a waterfall plot shows exactly which features moved a single patient’s predicted risk up or down. We look at the highest-risk, lowest-risk, and a borderline patient.
Explaining Individual Predictions
Explaining Individual Predictions
Explaining Individual Predictions