group_col so Thinking optimizes for unseen groups.
Setup
Install the client and dependencies (the current Thinking mode andgroup_col require tabpfn-client 0.7.1+).
In Colab, add TABPFN_TOKEN to Secrets; elsewhere, use your usual client authentication.
Choose the objective
Enable Thinking withthinking_mode=True (effort "medium") or pick an effort level
explicitly with thinking_effort, from fastest to most thorough: "micro", "mini",
"low", "medium", "high", "xhigh", "max". We use "high" here. Set
thinking_metric to match your task. Both examples below optimise log-loss for
calibrated class probabilities, and we report macro F1 alongside. See the
Thinking mode guide
for supported settings. Thinking runs an optimization over the training set at fit time, so fitting takes
minutes rather than seconds and grows with the number of rows and features. In this
notebook the fits take roughly 20 minutes on the first dataset and 3 to 10 minutes
on the second; prediction time is unchanged. The effort levels set a compute
budget, and on these datasets lower levels converge to the same solution.
We use TabPFN 3.5 throughout. The helper reports log-loss, macro F1 and elapsed
time, including fitting, prediction, and API overhead.
Scania trucks: air pressure system failures
Predict whether a truck’s air pressure system (APS) caused a breakdown from 170 anonymized sensor readings (UCI APS Failure at Scania Trucks, CC BY 4.0). Failures are rare, about 1.7% of trucks, so we optimise log-loss for calibrated failure probabilities and report macro F1 alongside. Both models use the same stratified 75/25 split. Lower log-loss is better. The high-effort fit on 57,000 rows and 170 features takes about 20 minutes; the standard fit takes seconds.
Thinking changes log-loss from 0.0142 to 0.0121 on this split, 15% lower, and
macro F1 from 0.9366 to 0.9450. The gain comes from the fit-time optimization,
which is why fitting took about 20 minutes instead of seconds.
Forest cover type: use group_col for unseen regions
The UCI Covertype dataset describes 30 m
forest cells in the Roosevelt National Forest with cartographic features such as
elevation, slope and soil type. The target is the dominant tree species.
We use the BeyondArena
version, which keeps three cover types and three wilderness areas and provides
splits that hold out entire wilderness areas. Rows from the same area share
climate and terrain, so this is grouped data: a model that generalizes to a new
area is more useful than one that interpolates within the areas it was trained on.
The target is not constant within an area; every area contains all three cover
types, so predictions and scores stay at the row level. The group only decides
which rows must be held out together.
Credit: Blackard (1998), CC BY 4.0.
Evaluate on an unseen wilderness area
The published fold trains on two wilderness areas and tests on the third. A random row split would leak: neighbouring cells from the same area would land on both sides, and the score would reward memorizing each area’s terrain rather than generalizing to a new one. The full fold is large, so we take a stratified sample of 50,000 training cells and 20,000 test cells, keeping the areas disjoint.Pass the group column
For grouped data, use Thinking withgroup_col="Wilderness_Area" and keep that
column in both training and prediction DataFrames. Thinking uses the column for
its own fit-time validation: rows of one area are never split between its internal
training and validation sets, so it optimizes for unseen areas instead of unseen
rows. That internal validation is separate from the outer holdout above, which
Thinking never sees. We compare four models on the
same held-out area: standard TabPFN, Thinking without the group column, Thinking
with it, and Thinking with it optimising macro F1 instead of log-loss, to show how
the choice of thinking_metric changes what improves. Soil descriptors are ordinal-encoded; the wilderness area is
only used as the group column, never as a feature. Expect about 10 minutes for
Thinking without the group column and 3 minutes for each grouped fit on 50,000 rows.
Results on the unseen area
Left: log-loss, which the first three Thinking fits optimise. Right: macro F1, which the last fit optimises.
Thinking with group_col changes log-loss from 0.7414 to 0.6881 on the unseen
area, 7% lower. Thinking without the group column is worse than standard TabPFN
(0.8446): it optimized for the two training areas and generalized worse to the
third. Macro F1 moves the other way for every Thinking fit, and optimizing
f1_macro directly does not recover it (0.4728): the calibrated probabilities
transfer to the new area, but the hard labels for the rare Krummholz class do
not. On grouped data, judge Thinking on the probability metric it optimizes,
and check label metrics on held-out groups before relying on them.
Takeaways
- Set
thinking_metricto match your task. - For grouped data, use
group_coland retain it at prediction time. Without it, Thinking can optimize for the groups it was trained on and generalize worse. - Evaluate on held-out data; for grouped data, hold out whole groups.