Estimating the number of clusters, k, is a fundamental prerequisite for most clustering algorithms. Traditionally, this estimation has relied on computationally expensive grid searches over internal cluster validity indices (CVIs) or adaptive clustering algorithms, both constrained by specific statistical assumptions. We introduce TabK, a zero-shot, permutation-invariant transformer architecture that frames the estimation of k as an amortized Bayesian inference problem for tabular data. TabK leverages a novel Quantile Feature Encoder (QFE) to extract position-free, content-derived representations from empirical marginal distributions. By learning a generalized structural bias over a diverse synthetic prior, TabK estimates the number of clusters in a single forward pass per ensemble member. Evaluated across 50 diverse real-world benchmarks, TabK outperforms all competing methods, achieving a mean absolute error (MAE) value of 1.04 compared to 2.14 for the closest competitor. TabK also achieves the lowest average inference time, producing estimates in less than one second on average and running 2× faster than TabClustPFN and 30× faster than traditional CVIs such as Silhouette and Calinski-Harabasz. Code is available at https://github.com/mrbakhtyari/TabK.
Figures & tables
Figure 1: Overview of the TabK architecture. The model processes the input matrix X via a double-invariant transformer and a Quantile Feature Encoder (QFE) for zero-shot k estimation.
Performance metrics
Wilcoxon test
Method
MAE ↓
ARI1↑
ARI2↑
EM (%) ↑
τ≤1 (%) ↑
Latency (s) ↓
p -value
TabK
1.04
0.232
0.221
50.0
80.0
0.67
–
SCARF+CH
2.14
0.218
0.207
28.0
52.0
71.3
1.5×10−3
TCP
2.24
0.210
0.213
38.0
56.0
1.50
6.5×10−3
CH
2.26
0.207
0.200
38.0
62.0
20.5
1.7×10−2
SubTab+Sil
2.38
0.214
0.213
40.0
58.0
35.2
1.3×10−2
Table 1: Aggregate performance on 50 OpenML benchmarks. TabK achieves the lowest MAE, and the highest Exact Match (EM) and ±1 Tolerance rates. ARI1 and ARI2 correspond to the ARIs obtained with k -means and GMM, respectively. Best results are bolded , second-best underlined .
Figure 2: Empirical evaluation on 50 OpenML real-world datasets. (a) MAE distributions. (b) Average Friedman ranks (Nemenyi test, α=0.05 ). (c) Cumulative accuracy at varying error tolerances ( τ ). (d) Efficiency-performance Pareto frontier. TabK demonstrates the highest accuracy and average ranking, the tightest error distribution, and the lowest latency among evaluated methods.
Figure 3: TabK performance across difficulty strata. MAE remains bounded across all oracle ARIs of k -means, whereas evaluated competitors exhibit high variance and marked failures. Datasets are grouped by oracle ARI into bins of width 0.1, and markers show the mean MAE per bin.
Figure 4: Head-to-head analysis of TabK vs. TabClustPFN (TCP). (a) Risk-coverage analysis showing TabK’s and TCP’s confidence ranking. (b) Log-log scalability plot demonstrating TabK’s order-of-magnitude speedup on GPU, with CPU execution frequently outpacing TCP on GPU.
Model variation
MAE ↓
Δ
Prior variation
MAE ↓
Δ
Architectural components
Prior volume
w/o QFE
1.82
+0.78
25% of synthetic prior
1.72
+0.68
w/o column attention
1.48
+0.44
50% of synthetic prior
1.46
+0.42
w/o PMA
1.38
+0.34
75% of synthetic prior
1.42
+0.38
Head formulations
Leave-one-generator-out
Ordinal
2.34
+1.30
w/o networked [ 15 ]
1.70
+0.66
Table 2: Ablation study results in terms of MAE evaluated across architectural components, predictive heads, and synthetic prior configurations. The Δ column indicates performance degradation relative to the full TabK model with an MAE of 1.04. Leave-one-generator-out removes a single generator from the prior mixture while keeping the total number of synthetic datasets fixed.
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
Strategy
Parameter
Value ranges / distributions
Rodriguez et al. [29]
α
Log-Uniform [0.05,5.0]
Fachada and de Andrade [9]
direction
Random Unit Vector
angle_disp
Uniform [0.1,0.6]
llength
Log-Uniform [10.0,60.0]
cluster_sep
(llength/m)×[0.1,0.6] per coordinate
llength_disp
llength×[0.6,1.1]
Appendix
Table 3: Hyperparameter specifications and sampling distributions used within our synthetic data generation strategies.
Figure 5: Visualization of synthetic geometries used for the generative prior ( n=1000,m=2,k=5 ): (a) Gaussian clusters [ 29 ] , (b) anisotropic ellipsoids [ 41 ] , (c) non-convex concentric shells, (d) networked manifolds [ 15 ] , and (e) elongated line-supported clusters [ 9 ] .
Hyperparameter
Symbol
Values
DLDL bandwidth
σ
0.1, 0.25, 0.5 , 1.0
Learning rate
η
10−4 , 2×10−4 , 5×10−4
Embedding dimension
dmodel
128, 256 , 512
QFE quantile bins
b
25, 50 , 100
Dropout rate
pdrop
0.1, 0.3 , 0.5
Attention heads
nhead
4, 8 , 16
Appendix
Table 4: Hyperparameter search space. Bold values denote the selected configuration for the final TabK model.
ID
Name
Objects ( n )
Features ( m )
k
#Missing
#Categorical
2
anneal
898
38
5
22175
32
3
kr-vs-kp
3196
36
2
0
36
4
labor
57
16
2
326
8
10
lymph
148
18
4
0
15
14
mfeat-fourier
2000
76
10
0
0
15
breast-w
699
9
2
16
0
Appendix
Table 5: Summary of the 50 real-world benchmarks used in our evaluation. OpenML dataset IDs are provided for reproducibility. n : number of objects, m : number of features, k : ground-truth number of clusters.
Generative strategy
MAE ↓
Exact Match (%) ↑
τ≤1 (%) ↑
Concentric Hyperspheres
1.17
47.3
73.6
Rodriguez et al. [29]
1.27
52.3
73.6
Fachada and de Andrade [9]
1.56
41.5
66.3
Jahn et al. [15]
1.76
43.8
65.3
Zellinger and Bühlmann [41]
2.05
42.3
61.8
Overall synthetic holdout
1.56
45.5
68.2
Appendix
Table 6: TabK performance on the 10% synthetic holdout set, stratified by generative strategy. The model demonstrates competitive exact recovery and ±1 Tolerance ( τ≤1 ) across diverse geometric domains.
Figure 6: Structural sensitivity analysis. MAE stratified by ground-truth number of clusters ( k ), objects ( n ), and features ( m ). TabK maintains consistent performance across all structural regimes.
Figure 7: MAE stratified by the missing values and categorical features. TabK exhibits a bounded and consistent error profile across all evaluated domains compared to baseline methods and state-of-the-art TabClustPFN.
Table 8: Evaluation of TabK’s structural inference stability under uniform row subsampling. Results are aggregated over 15 independent trials for each sample size. The metrics demonstrate that TabK structural inference remains stable across a wide range of sample sizes.
Perturbation
Level
MAE ↓
Agreement (%) ↑
None (clean)
–
1.04
100.0
Noisy features
+25% of m
1.43
86.8
+50% of m
1.56
85.6
+100% of m
1.94
76.8
Diffuse outliers
1% of n
1.30
80.4
5% of n
1.43
68.0
Appendix
Table 9: TabK under noisy features and diffuse outliers on the 50 benchmarks (mean over five seeds). Agreement is the percentage of datasets on which the prediction matches the prediction on clean data.
Subset
Method
MAE ↓
EM (%) ↑
τ≤1 (%) ↑
Brier ↓
NLL ↓
Latency (s) ↓
CC18, all (25)
TabK
1.56
44.0
60.0
0.718
2.106
0.70
TCP
2.60
40.0
56.0
0.897
5.274
4.31
CC18, > 500k cells (10)
TabK
1.00
60.0
80.0
0.542
1.238
1.66
TCP
2.00
50.0
70.0
0.904
6.180
9.88
Appendix
Table 10: Evaluation beyond the primary benchmark. OpenML-CC18: 25 datasets disjoint from the primary benchmark and from the datasets used to estimate the prior’s (k,n,m) marginals; the > 500k subset exceeds the largest synthetic training table.
ID
Dataset
n
m
Cells
k∗
TabK
TCP
1480
ilpd
583
12
6,996
2
2
2
469
analcatdata_dmft
797
9
7,173
6
2
10
40994
climate-model-simulation-crashes
540
18
9,720
2
2
2
23
cmc
1,473
9
13,257
3
7
2
1489
phoneme
5,404
5
27,020
2
4
9
40982
steel-plates-fault
1,941
27
52,407
7
2
10
Appendix
Table 11: Per-dataset predictions kˉ on the 25 OpenML-CC18 datasets used for the scale evaluation, ordered by table size. Bold entries indicate exact recovery; underlined entries indicate ∣kˉ−k∗∣=1 .
ID
k∗
TabK
SCARF+CH
TCP
CH
SubTab+Sil
SCARF+Sil
IMWk
VIME+Sil
VIME+CH
Sil
CNAK
SubTab+CH
DB
Dunn
GMM-BIC
X-Means
Gap
UNSEEN
2
5
2
5
2
3
15
3
4
15
2
8
2
14
12
4
5
15
2
13
3
2
2
4
2
2
9
2
4
2
2
7
2
3
15
13
5
15
2
15
4
2
3
2
10
2
2
3
4
2
2
15
2
2
15
14
4
2
3
15
10
4
3
3
2
2
3
4
4
2
2
2
2
5
14
7
3
2
2
15
14
10
10
3
10
2
2
2
8
15
2
2
3
2
15
3
3
15
15
15
15
2
2
5
3
2
2
2
7
2
3
2
2
2
2
5
15
6
8
11
Appendix
Table 12: Predicted numbers of clusters, kˉ , reported for the 50 OpenML benchmarks. OpenML dataset IDs are indicated. Methods are ordered by the MAE performance (best first). Bold entries indicate exact recovery ( kˉ=k∗ ). Underlined entries indicate a prediction with τ≤1 ( ∣kˉ−k∗∣=1 ).