Skip to content

Tabular, time-series, scientific, and geometric deep learning · Tabular deep learning · SPE004 · Model

TabPFN family

TabPFN amortizes prediction over a distribution of synthetic tabular tasks. A pretrained network conditions on labeled training rows and query rows, producing task predictions without necessarily optimizing its weights…

Runs in CodeSplash (Experimental) Complete calculation CodeSplash's run and the reference's record

In CodeSplash

A CodeSplash method runs this entry in Python and R. Set it up from the method's page. The methods that run it are Experimental.

Do it in CodeSplash Run it on your own data. It's in the Experimental lane in the app.

Availability
Runs in CodeSplash (Experimental)
Code example
Complete calculation
Who ran it
CodeSplash's run and the reference's record
CodeSplash's run
The reference's example ran in Python and R here, and they agree.
The reference's record
Python: Ran in the reference's review. The report doesn't record which version of the code ran. R: Reviewed but not run: R wasn't available to the reference's authors.

Purpose

TabPFN amortizes prediction over a distribution of synthetic tabular tasks. A pretrained network conditions on labeled training rows and query rows, producing task predictions without necessarily optimizing its weights for each new table. Later family versions extend beyond the original small classification setting.

Question / hypotheses

The operative question is whether the specified representation, symmetry, likelihood or physical constraint improves held-out behavior for this data domain. This is a learning framework, not a null-hypothesis test; losses, attention weights and predictive confidence are not statistical p-values.

Architecture / computational structure

A prior-data fitted network is pretrained on synthetic datasets to approximate posterior-predictive behavior. Transformer processing treats the supplied labeled dataset as inference context. Checkpoint generations have different supported tasks, limits and interfaces; they are one family here.

Assumptions

Generalization depends on the task prior and compatibility of schema/statistics with pretraining. Context conditioning is not proof of Bayesian calibration under the real data-generating process. Group leakage, temporal leakage and rare categories remain serious concerns.

Formula / computational definition

L=ED∼p(D)[−log⁡qθ(y∗∣x∗,Dtrain)]L=E_{D\sim p(D)}[-\log q_\theta(y_*\mid x_*,D_{train})]. The target is a prior-predictive conditional distribution, p(y∗∣x∗,D)=∫p(y∗∣x∗,h)p(h∣D)dhp(y_*\mid x_*,D)=\int p(y_*\mid x_*,h)p(h\mid D)dh, over latent hypotheses hh.

Parameters and notation

Learned or estimated: Transformer and output-distribution parameters are learned in pretraining. The target table becomes context; ordinary estimator fitting may prepare context/preprocessing rather than run gradient descent on these weights.

Hyperparameters and effects: Checkpoint/version, preprocessing ensembles, feature/category handling, context size, inference configuration and optional adaptation schedule. Model support and defaults are version-dependent; record them rather than assuming original-paper limits apply to every release.

Fitting, fine-tuning, and adaptation

Start with fixed-weight contextual inference and a leakage-safe training/validation split. If using a version-supported gradient fine-tuning workflow, distinguish it from context setup, use a small learning rate and monitor target validation plus source retention. Calibrate probabilities separately; check whether gains justify extra adaptation cost.

How to use and calibrate

Define the independent evaluation unit before preprocessing: row/entity, whole set/object, molecule/trajectory, input function or chronological forecasting origin. Keep target construction and normalization within permitted training data. Compare with well-tuned trees and linear baselines at matched data access. Report calibration, uncertainty coverage for regression, latency including context processing, and performance under data shift.

Example application

Build a small-sample tabular baseline while documenting whether adaptation is contextual or gradient-based. This is a proposed use case, not a claim of validated performance on supplied real data.

Interpretation / pitfalls

Watch out

Assess model error against domain baselines and the stated assumptions. Component-level mathematical correctness does not establish paper reproduction or scientific validity. Use an independent validation design for model selection and a final held-out evaluation for claims; uncertainty and calibration require separate assessment.

Python and R code examples

Scope: Exact two-hypothesis posterior-predictive target illustrating what a PFN amortizes; NOT TabPFN inference. Use the shared setup. Dependencies: NumPy / base R. Validation: Python executed; R unexecuted.

Full-model route: Python: version-pinned official TabPFN package; R: explicit reticulate bridge for actual checkpoints. The educational code computes a two-hypothesis posterior-predictive target; it is not an implementation or execution of TabPFN.

Python and R

The reference's own programs, shown as written. A component demo shows one central piece of the method; it doesn't train a full model.

Python

Complete calculation — Exact two-hypothesis posterior-predictive target illustrating what a PFN amortizes; NOT TabPFN inference. Use the shared setup.

Shared setup for this chapter
import numpy as np
def sm(x):
    x=np.asarray(x); e=np.exp(x-x.max(axis=-1,keepdims=True)); return e/e.sum(axis=-1,keepdims=True)
prior=np.array([.5,.5]); y=np.array([0,1])
p_training=np.array([[.2,.8],[.6,.4]]) # hypothesis by labeled observation
likelihood=np.prod(np.where(y[None,:]==1,p_training,1-p_training),axis=1)
posterior=prior*likelihood; posterior/=posterior.sum()
p_query=np.array([.7,.3]); prediction=posterior@p_query
print('hypothesis posterior',posterior,'query probability',prediction)
R

Complete calculation — Exact two-hypothesis posterior-predictive target illustrating what a PFN amortizes; NOT TabPFN inference. Use the shared setup.

Shared setup for this chapter
sm <- function(x) {
  if(is.null(dim(x))) { e<-exp(x-max(x)); return(e/sum(e)) }
  t(apply(x,1,function(v) { e<-exp(v-max(v)); e/sum(e) }))
}
prior<-c(.5,.5); y<-c(0,1)
p_training<-matrix(c(.2,.8,.6,.4),2,byrow=TRUE)
likelihood<-apply(p_training,1,function(p) prod(ifelse(y==1,p,1-p)))
posterior<-prior*likelihood; posterior<-posterior/sum(posterior)
p_query<-c(.7,.3); prediction<-sum(posterior*p_query)
print(list(hypothesis_posterior=posterior,query_probability=prediction))

Sources

From the CodeSplash reference, entry SPE004.