GAMformer: Bridging Tabular Foundation Models and Interpretable Machine Learning

Andreas Mueller, Julien Siems, Harsha Nori, David Salinas, Arber Zela, Rich Caruana, Frank Hutter

TL;DR

GAMformer is the first tabular foundation model designed for Generalized Additive Models (GAMs), successfully bridging the gap between the speed of foundation models and the transparency of interpretable machine learning. By leveraging in-context learning, it estimates fully interpretable feature shape functions in a single forward pass, matching the accuracy of traditional iterative GAMs and tree-based models like XGBoost.

What Problem Does This Paper Address?

In safety-critical domains like healthcare and finance, machine learning models cannot afford to be black boxes; regulatory compliance and human trust demand interpretability. Generalized Additive Models (GAMs) are a popular solution because they break down predictions into a sum of univariate "shape functions" (one for each feature), making it easy for practitioners to see exactly how each variable impacts the final output.

However, traditional GAMs rely on iterative learning algorithms—such as splines, boosted trees, or neural networks—to fit these shape functions. This iterative nature makes them fundamentally incompatible with the emerging paradigm of tabular foundation models (like TabPFN), which predict outcomes instantly via a single forward pass using In-Context Learning (ICL).

The authors introduce GAMformer to resolve this tension, creating a tabular foundation model that delivers both the instant inference of transformers and the rigorous transparency of GAMs.

Methods

GAMformer replaces the manual, iterative data-fitting loops of traditional GAMs with a differentiable, two-step transformer architecture.

Figure 1: GAMformer’s forward pass on a new dataset with three features (x1, x2, x3) and label y and two training and one test-data point: (1) For each training data point, we bin all features, one-hot encode them, embed the resulting vectors and add the label of the data point. (2) We alternate between applying attention across the features and the data points, allowing us to handle varying numbers of each. (3) We decode per-feature shape functions using a shared MLP decoder. (4) We infer the prediction for test data points by looking up and adding each feature’s shape function value (red bins) forming the GAM prediction. (5) Finally, we compute the loss based on the prediction allowing the end-to-end training of the shape function estimation based on (in our case, synthetic) training datasets.

The pipeline operates as follows:

  1. Feature Preprocessing & Binning: To naturally capture sudden jumps and discontinuities in data, GAMformer discretizes each feature into 64 non-parametric bins based on quantiles. These binned features are one-hot encoded and embedded alongside their corresponding labels.
  2. Bi-Attention Backbone: The model passes these embeddings through 12 transformer layers that alternate between column-wise attention (interactions across features within a data point) and row-wise attention (interactions across different data points for a given feature). This ensures permutation equivariance and allows the model to handle tables of varying sizes.
  3. Shape Function Decoding: A shared Multi-Layer Perceptron (MLP) decodes the transformer's final embeddings into discrete shape functions for each feature.
  4. GAM Inference: For a new test point, the model simply looks up the corresponding bin value on each feature's learned shape function and sums them up to produce the final prediction.

To handle complex datasets, the authors also extend GAMformer to capture higher-order effects (pairwise interactions) by ranking feature products using the FAST method and performing ICL on the expanded feature set.

Datasets

To prevent data leakage and ensure robust generalization, GAMformer is trained exclusively on synthetic data priors:

  • Structural Causal Models (SCMs): Used to generate diverse tabular structures capturing causal relationships (96% of training data).
  • Gaussian Processes (GPs): Used to help the model learn smoother functional relationships (4% of training data).

For evaluation and real-world case studies, the authors test GAMformer on:

  • MIMIC-II & MIMIC-III: Publicly available critical care datasets used to predict ICU mortality risk.
  • California Housing Dataset: A standard regression benchmark for predicting median house values.
  • OpenML Tabular Benchmark: A suite of 30 diverse tabular classification datasets containing up to 2,000 samples, 100 features, and 10 classes.

Key Insights and Ideas

  • The Power of Binned Representations: Unlike neural additive models that use smooth MLPs, GAMformer’s discrete, binned representation allows it to naturally model sharp discontinuities. This is vital for capturing real-world phenomena like sudden treatment effects in medical data.
  • Automated Data Debugging: In the MIMIC-II case study, GAMformer successfully exposed a data preprocessing artifact. It isolated a sharp drop in mortality risk at a PFratio of ~325, which corresponds to where missing values had been imputed at the mean by previous researchers.
Figure 6: Classification: Shape functions derived from GAMformer and EBMs applied to the MIMIC-II dataset for critical clinical variables. The data density plot is shown above each figure. The results are based on 30 models for both GAMformer and EBMs, each fitted on 10,000 randomly selected data points.
  • Amortizing the Carbon Footprint: While pre-training GAMformer is computationally expensive (600 hours on an A100 GPU), its inference is incredibly cheap (0.170s per run). The authors calculate that GAMformer's carbon cost breaks even with retraining an Explainable Boosting Machine (EBM) after 7.7 million runs—a highly feasible number for widely deployed foundation models.

Key Results

  • Classification Performance: On the 30 OpenML datasets, GAMformer outperformed spline-based GAMs (mgcv) and traditional EBMs when evaluating main effects.
  • Matching XGBoost: When extended with pairwise interactions (GAMformer*), the model achieved predictive performance on par with state-of-the-art tree-boosting methods like XGBoost, proving that main-effects models sacrifice less predictive power than commonly assumed.
  • Robustness: The model demonstrated strong resilience against severe class imbalance and high levels of label noise, despite never seeing real-world data during its training phase.

Limitations and Future Work

Despite its strong performance, GAMformer faces a few notable constraints:

  • Context Length Limitations: Like many transformer-based models, GAMformer struggles with length extrapolation. Its performance plateaus or degrades when evaluated on datasets that are more than twice the size of the context window seen during training (i.e., >1,000 samples).
  • Higher-Order Interactions: The core architecture is restricted to main and second-order effects, meaning it cannot natively capture complex, multi-variable interactions without explicit feature engineering.

Future Directions: The authors suggest exploring more scalable transformer architectures (such as linear attention mechanisms seen in TabFlex) to handle larger datasets, and combining GAMformer with causal foundation models to estimate full structural causal graphs.

Summary updated

BibTeX
@misc{mueller2024gamformer,
  author = {Andreas Mueller and Julien Siems and Harsha Nori and David Salinas and Arber Zela and Rich Caruana and Frank Hutter},
  title = {{GAMformer: Bridging Tabular Foundation Models and Interpretable Machine Learning}},
  year = {2024},
  eprint = {2410.04560},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.04560},
}
Figure