TabK: Amortized Bayesian Estimation of the Number of Clusters in Tabular Data
Organizations: Université du Québec à Montréal, Canada · Mila, Canada · University of Essex, UK · DIRO, Université de Montréal, Canada
Abstract
Estimating the number of clusters, , 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 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 faster than TabClustPFN and faster than traditional CVIs such as Silhouette and Calinski-Harabasz. Code is available at https://github.com/mrbakhtyari/TabK.
Figures & tables
| Performance metrics | Wilcoxon test | ||||||
|---|---|---|---|---|---|---|---|
| Method | MAE | EM (%) | (%) | Latency (s) | -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 | |
| TCP | 2.24 | 0.210 | 0.213 | 38.0 | 56.0 | 1.50 | |
| CH | 2.26 | 0.207 | 0.200 | 38.0 | 62.0 | 20.5 | |
| SubTab+Sil | 2.38 | 0.214 | 0.213 | 40.0 | 58.0 | 35.2 | |
| 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 |
Appendix figures & tables13 assets
Supplementary material from the paper’s appendix.
Appendix
| Strategy | Parameter | Value ranges / distributions |
| Rodriguez et al. [29] | Log-Uniform | |
| Fachada and de Andrade [9] | direction | Random Unit Vector |
| angle_disp | Uniform | |
| llength | Log-Uniform | |
| cluster_sep | per coordinate | |
| llength_disp |
| Hyperparameter | Symbol | Values |
|---|---|---|
| DLDL bandwidth | 0.1, 0.25, , 1.0 | |
| Learning rate | , , | |
| Embedding dimension | 128, , 512 | |
| QFE quantile bins | 25, , 100 | |
| Dropout rate | 0.1, , 0.5 | |
| Attention heads | 4, , 16 |
| ID | Name | Objects ( ) | Features ( ) | #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 |
| Generative strategy | MAE | Exact Match (%) | (%) |
|---|---|---|---|
| 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 |
| Method | MAE | ARI ( -means) | EM (%) | (%) | Latency (s) |
|---|---|---|---|---|---|
| TabK | 0.78 | 0.269 | 55.6 | 85.2 | 0.08 |
| TabClustPFN | 2.56 | 0.235 | 29.6 | 59.3 | 0.50 |
| Sample size | Exact Match rate vs. Full | Mean vs. Full | Latency (ms) |
|---|---|---|---|
| 94.3% | 0.16 | 33.91 | |
| 89.5% | 0.18 | 25.83 | |
| 90.5% | 0.34 | 20.44 | |
| 86.7% | 0.34 | 20.96 | |
| 75.2% | 0.62 | 19.27 | |
| 61.9% | 0.73 | 19.20 |
| Perturbation | Level | MAE | Agreement (%) |
|---|---|---|---|
| None (clean) | – | 1.04 | 100.0 |
| Noisy features | +25% of | 1.43 | 86.8 |
| +50% of | 1.56 | 85.6 | |
| +100% of | 1.94 | 76.8 | |
| Diffuse outliers | 1% of | 1.30 | 80.4 |
| 5% of | 1.43 | 68.0 |
| Subset | Method | MAE | EM (%) | (%) | 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 |
| ID | Dataset | Cells | 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 |
| ID | 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 |