GAMformer: In-Context Learning for Generalized Additive Models

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

Abstract

Generalized Additive Models (GAMs) are widely recognized for their ability to create fully interpretable machine learning models for tabular data. Traditionally, training GAMs involves iterative learning algorithms, such as splines, boosted trees, or neural networks, which refine the additive components through repeated error reduction. In this paper, we introduce GAMformer, the first method to leverage in-context learning to estimate shape functions of a GAM in a single forward pass, representing a significant departure from the conventional iterative approaches to GAM fitting. Building on previous research applying in-context learning to tabular data, we exclusively use complex, synthetic data to train GAMformer, yet find it extrapolates well to real-world data. Our experiments show that GAMformer performs on par with other leading GAMs across various classification benchmarks while generating highly interpretable shape functions.

Introduction

In high-stakes domains like healthcare and finance, "black-box" models are often unacceptable due to regulatory requirements and safety concerns. Practitioners frequently turn to Generalized Additive Models (GAMs), which offer high interpretability by decomposing predictions into a sum of univariate "shape functions"—one for each feature.

However, traditional GAMs, such as Explainable Boosting Machines (EBMs) or spline-based models, rely on iterative learning algorithms. These methods are often slow and fundamentally incompatible with the emerging paradigm of tabular foundation models (e.g., TabPFN), which are powerful and fast but lack inherent transparency. GAMformer bridges this gap, creating a foundation model that produces an interpretable model structure in a single forward pass.

Architecture and Methodology

GAMformer utilizes a transformer-based architecture designed to estimate GAM shape functions using In-Context Learning (ICL). The model features a 12-layer backbone employing "bi-attention," which alternates between column-wise attention (interactions across features) and row-wise attention (interactions across data points). This design ensures the model is permutation-equivariant.

GAMformer architecture overview showing shape function estimation and inference.

Instead of predicting weights for a neural network, GAMformer predicts a discrete, binned representation (64 bins) for each feature's shape function. This allows the model to capture sudden "jumps" or discontinuities in data, such as specific medical treatment thresholds. Unlike traditional models that require iterative fitting (backfitting or gradient boosting), GAMformer estimates all shape functions simultaneously. The model is trained exclusively on synthetic data generated via Structural Causal Models (SCMs) and Gaussian Processes (GPs), allowing it to learn a wide variety of functional relationships without data leakage.

Experimental Evaluation

GAMformer was trained on over 100 million synthetically generated tables and evaluated across several real-world benchmarks:

  • MIMIC-II & MIMIC-III: Real-world clinical datasets used to predict intensive care unit (ICU) mortality risk.
  • California Housing: A standard regression benchmark for predicting house prices.
  • OpenML Tabular Benchmark: A suite of 30 diverse classification datasets used to compare GAMformer against state-of-the-art baselines like XGBoost and TabPFN.

Results and Interpretability

On the OpenML benchmark, GAMformer outperformed traditional spline-based GAMs and matched the performance of EBMs. When extended to include pairwise feature interactions (GAMformer), the model performed on par with XGBoost*, a significant achievement for a model that remains largely interpretable.

Shape functions recovered by GAMformer on real-world clinical data (MIMIC-II), showing alignment with known medical trends.

In the MIMIC-II case study, GAMformer successfully recovered well-known clinical trends, such as the U-shaped risk profile for heart rate and the sharp risk increase associated with low oxygen saturation (PFratio). The model also demonstrated high resilience to label noise and class imbalance, often outperforming EBMs in highly imbalanced scenarios.

Discussion and Future Work

The development of GAMformer demonstrates that foundation models do not have to be black boxes. By forcing the transformer to output the components of a GAM, we achieve the speed of a pre-trained model with the "glass-box" transparency of a linear-style model. While pre-training is computationally expensive (600 hours on an A100 GPU), the cost is amortized; after approximately 7.7 million runs, GAMformer becomes more carbon-efficient than repeatedly retraining iterative models.

Currently, GAMformer struggles with length extrapolation when test sets significantly exceed the training context window (optimized for ~500-1000 points). Future work will explore higher-order interactions beyond pairwise effects and linear attention mechanisms to improve scalability for larger datasets.

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: In-Context Learning for Generalized Additive Models}},
  year = {2024},
  eprint = {2410.04560},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2410.04560},
}
Figure