GAMformer: In-Context Learning for Generalized Additive Models

Andreas C Mueller, Julien Siems, Harsha Nori, David Salinas, Arber Zela, Rich Caruana, Frank Hutter · Submission to ICLR 2025 · Rejected

TL;DR

GAMformer brings the paradigm of in-context learning to Generalized Additive Models (GAMs), estimating fully interpretable, non-parametric shape functions in a single transformer forward pass. Trained exclusively on synthetic data, it eliminates iterative optimization and hyperparameter tuning while matching the predictive accuracy of leading GAM variants like Explainable Boosting Machines (EBMs).

What Problem Does This Paper Address?

Generalized Additive Models (GAMs) are a gold standard for interpretable machine learning on tabular data. By expressing predictions as a sum of individual univariate non-linear transformations ($g(E[y|x]) = \beta + \sum f_i(x_i)$), they allow human experts to directly inspect the marginal impact of every feature.

However, existing GAMs—whether based on splines, boosted trees (EBMs), or neural nets (NAMs)—rely on iterative training loops (e.g., backfitting, round-robin boosting, or gradient descent). These require extensive hyperparameter tuning (learning rates, regularization, splines/tree depth) and can be computationally cumbersome. While recent foundation models for tabular data (like TabPFN) achieve zero-shot in-context learning without iterative fitting, they function as black boxes. GAMformer bridges this gap: applying in-context learning directly to produce modular, interpretable shape functions in a single shot.

Methods

Instead of optimizing shape functions through iterative updates on a new dataset, GAMformer casts shape function estimation as an in-context learning task:

  1. Feature Preprocessing & Binning: Continuous features are discretized into 64 quantile-based bins, one-hot encoded, and projected via an MLP embedding. Data point labels are added to each feature embedding.
  2. Dual-Module Attention Architecture: A 12-layer transformer alternates self-attention across features and data points. This permutation-equivariant design handles variable numbers of features and samples without requiring fixed padding.
  3. Discrete Shape Function Decoding: Rather than outputting neural network weights or spline coefficients, embeddings are pooled across training classes and passed to a shared MLP decoder that outputs binned values ($\tilde{f} \in \mathbb{R}^{p \times 64 \times m}$) for each feature and class.
  4. Instant Inference: For test samples, the model performs table lookups on the discretized bins and sums the values across features.
  5. Synthetic Prior Training: The model is trained purely on synthetic priors (96% Structural Causal Models and 4% Gaussian Processes) over 100M+ generated datasets using cross-entropy loss on held-out samples.
  6. Pairwise Interactions: GAMformer models pairwise effects by ranking feature interactions using the FAST algorithm and selecting top pairs via validation passes.

Datasets

  • Pretraining: 100% synthetically generated datasets using Structural Causal Models (SCMs) and Gaussian Processes (GPs).
  • Evaluations & Benchmarks:
  • Synthetic & Toy Datasets: Linear and polynomial decision boundaries, and scikit-learn toy classification sets (e.g., XOR).
  • Tabular Benchmarks: 30 OpenML classification datasets (up to 2,000 samples, 100 features, and 10 classes) established by TabPFN.
  • Real-World Binary Benchmarks: Telco Churn, Adult (Census Income), SUPPORT2, MIMIC-II, and MIMIC-III clinical datasets.

Key Insights and Ideas

  • In-Context Interpretability: Demonstrates that meta-learning / Prior-Data Fitted Networks (PFNs) are not limited to black-box predictions; they can directly emit inspectable model representations (shape functions).
  • Inherent Regularization & Smoothness: Due to its pretraining priors, GAMformer naturally discovers smoother shape functions than tree-based EBMs without requiring explicit smoothness penalty tuning.
  • Artifact Detection: In clinical data (MIMIC-II), GAMformer cleanly isolates preprocessing artifacts—such as mean-imputed missing values in oxygenation ratios (PFratio at ~325)—more sharply than baseline GAMs.
  • Fast Test-Time Scoring: While computing the shape functions scales quadratically during the in-context step, inference on test points requires only simple array lookups and additions, scaling linearly $O(p)$.

Key Results

  • Benchmark Performance: On the 30 OpenML classification tasks, GAMformer with main effects statistically outperformed main-effects EBM. With pairwise interactions included, GAMformer matched the performance of XGBoost and EBM.
  • Real-World Transfer: On benchmarks like Adult and MIMIC-II, GAMformer scored 90.05% and 82.22% ROC-AUC, closely matching or outperforming standard GAM baselines (e.g., pyGAM at 83.89% on MIMIC-II and Logistic Regression at 81.62%) without any fine-tuning.
  • Robustness: Experiments demonstrated that GAMformer is as robust as EBMs to extreme label noise and class imbalance.

Limitations and Future Work

  • Context Length Generalization: GAMformer was pretrained on datasets with up to 500 samples. When evaluated on datasets with over 1,000–2,000 instances, performance improvements plateaued, showing transformers' standard difficulty with length extrapolation.
  • Quadratic Scaling: The full self-attention mechanism scales quadratically with both feature count and sample count. The authors point to linear-time architectures (such as Mamba or Gated Linear Attention) as promising replacements.
  • Higher-Order Terms: Currently, higher-order interactions require a multi-stage heuristic search (FAST) rather than being discovered natively end-to-end.

Summary updated

BibTeX
@misc{mueller2024gamformer,
  author = {Andreas C Mueller and Julien Siems and Harsha Nori and David Salinas and Arber Zela and Rich Caruana and Frank Hutter},
  title = {{GAMformer: In-Context Learning for Generalized Additive Models}},
  year = {2024},
  eprint = {2410.04560},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.04560},
}

Loading related content...

Figure