This explains the model’s computation. It does not show that a training row caused heart disease, and it is not medical advice.
Setup
Install the local TabPFN model, the decoder helpers, and UMAP for clear 2D views. The decoder readout needs the local model because it reads an internal attention layer. The hosted API does not expose this layer.TABPFN_TOKEN to Colab secrets. This cell leaves existing local authentication unchanged.
Load Heart Statlog
Use short names so the rows stay easy to scan. Heart Statlog has 270 rows, 13 patient features, and two classes. We keep 200 rows for training and 70 for testing.
Fit TabPFN
Read the Decoder Votes
Recover one weight for every test-row/training-row pair. For a given test row, all training-row weights are non-negative and sum to one. Adding the weights within each class gives that class’s vote.One Prediction as a Table
Start with the most uncertain test row. This row has a heart-disease vote closest to 50%. The table ranks the training rows by decoder weight. Its first rows had the strongest vote.
One Prediction in Raw Feature Space
Place the test row and its strongest voters on a 2D map of the original columns. The star is the test row. A line joins it to each of its 20 strongest training rows. Thicker lines mean larger weights. Blue and orange mark the training class.
The Same Prediction in Embedding Space
TabPFN turns each row into a learned embedding before the decoder acts. This view projects those embeddings to 2D. It often places the strongest voters closer to the star and separates the two classes more clearly.
The raw and embedding plots show exactly the same decoder weights. Only the map changes. UMAP compresses many dimensions into two, so distances in either picture are useful summaries, not exact model distances.
Four Predictions Together
Compare confident and uncertain votes in one view. We choose the lowest heart-disease predicted probability, the two observations nearest the 50% predicted probability from either side, and the largest predicted probability.Combined raw-feature view
The original feature map can mix rows from the two classes. Strong decoder links may cross large parts of this 2D view.
Combined embedding view
In the learned map, the same links tend to stay within clearer class regions. This is the space that best reveals what the decoder keys on.
What to Keep
- A decoder weight says how much one training row voted for one test row.
- Summing weights by class gives the class vote.
- The table is exact; the 2D maps are visual summaries.
- Raw space shows observations in the raw feature space. Embedding space is closer to the model’s own view.