NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

GAMformer: Exploring In-Context Learning for Generalized Additive Models

Andreas C Mueller, Julien Siems, Harsha Nori, Rich Caruana, Frank HutterInterpretableAI @ NeurIPS 2024

TL;DR

This paper introduces GAMformer, a novel approach to building interpretable Generalized Additive Models (GAMs) by leveraging in-context learning. Instead of traditional iterative training, GAMformer estimates model components in a single forward pass, achieving competitive accuracy with existing methods while offering enhanced interpretability and efficiency.

What Problem Does This Paper Address?

Interpretable machine learning models are crucial for trust, fairness, and accountability, especially in high-stakes domains like healthcare and finance. Generalized Additive Models (GAMs) offer a good balance of accuracy and interpretability by modeling a target variable as a sum of non-linear functions of individual features. However, traditional GAM training methods, such as those using splines, boosted trees, or neural networks, rely on iterative optimization algorithms. This iterative process introduces complexity, requires hyperparameter tuning, and can be computationally expensive. The paper aims to address this by developing a GAM fitting method that bypasses iterative optimization, making GAMs more efficient and accessible.

Methods

The core innovation of GAMformer is its use of in-context learning (ICL) to estimate the shape functions of a GAM. This approach draws inspiration from recent work on applying ICL to tabular data, particularly models like TabPFN.

Here's a breakdown of the GAMformer method:

  • In-Context Learning (ICL): Instead of updating model weights through gradient descent on a specific dataset, GAMformer leverages a pre-trained transformer model. This model is presented with "in-context examples" (training data) and learns to perform the task (estimating shape functions) in a single forward pass, without any parameter updates.
  • Transformer Architecture: A transformer model with 12 hidden layers is used. It's designed to be agnostic to the number of features and data points by alternating self-attention mechanisms over features and then over data points.
  • Non-parametric Shape Function Representation: GAMformer represents shape functions discretely using 64 bins. This allows for capturing sudden discontinuities and avoids imposing a specific functional form, unlike traditional spline-based methods.
  • End-to-End Training: The entire GAMformer model, including the shape function estimation, is trained end-to-end on large-scale synthetic datasets. The training objective is to minimize the difference between the GAM's prediction (sum of estimated shape functions) and the ground truth labels.
  • Higher-Order Effects: The framework can be extended to model pairwise interactions by incorporating feature products, though this increases dimensionality. The authors propose ranking informative pairs and using cross-validation to select the optimal number of pairs.

Datasets

GAMformer is trained exclusively on complex, synthetic datasets generated using two priors:

  1. Structural Causal Models (SCMs): These models capture causal relationships between variables, providing a strong prior for tabular data.
  2. Gaussian Processes (GPs): GPs are used to generate smoother functions.

For evaluation, GAMformer is tested on:

  • Illustrative Examples: Synthetic datasets for linear and polynomial binary classification problems.
  • Real-world Tabular Datasets:
    • Scikit-learn datasets: Used for visualizing classification boundaries.
  • OpenML datasets: A collection of 30 datasets used in prior work (Hollmann et al. [17]), featuring up to 2000 samples, 100 features, and 10 classes.
  • MIMIC-II and MIMIC-III datasets: Publicly available clinical datasets from intensive care units, used for a case study on predicting mortality risk.
  • SUPPORT2 dataset: Another clinical dataset for predicting mortality risk.

Key Insights and Ideas

  • ICL for GAMs is Viable: The paper demonstrates that in-context learning, a paradigm previously explored in NLP and other domains, can be effectively applied to learn GAM shape functions for tabular data. This opens up a new avenue for efficient GAM fitting.
  • Single Forward Pass Efficiency: By replacing iterative optimization with a single forward pass of a pre-trained transformer, GAMformer offers significant computational advantages, especially for inference.
  • Extrapolation to Real-World Data: Despite being trained solely on synthetic data, GAMformer shows strong performance on diverse real-world datasets, highlighting the power of its pre-training strategy.
  • Smoother Shape Functions: GAMformer tends to produce smoother shape functions compared to methods like EBMs, potentially due to inductive biases from its pre-training on synthetic data. This can be beneficial for interpretability.
  • Handling Data Artifacts: In the MIMIC-II case study, GAMformer was able to more precisely isolate patterns related to data processing artifacts (e.g., missing PFratio values) than EBMs, showcasing its potential for data quality assessment.

Key Results

  • Competitive Accuracy: GAMformer achieves accuracy comparable to or exceeding state-of-the-art GAMs (like EBMs) and other tabular models (like XGBoost and TabPFN) across various classification benchmarks. For instance, on the linear binary classification problem, both GAMformer and EBM achieved an ROC-AUC of 1.0.
  • Robustness: GAMformer demonstrates robustness to class imbalance and noisy labels, performing on par with EBMs in these challenging scenarios.
  • Scalability: The model shows improved performance as the number of training data points increases, up to twice the number seen during training, indicating good generalization capabilities.
  • Interpretability: The generated shape functions are highly interpretable, allowing for visual inspection of feature effects, similar to traditional GAMs.

Limitations and Future Work

  • Limited to Main and Second-Order Effects: The current GAMformer implementation primarily focuses on main effects and pairwise interactions. Future work could explore incorporating higher-order interactions, which are handled by other GAM methods.
  • Length Extrapolation Challenge: Similar to other sequence-to-sequence models, GAMformer faces challenges with length extrapolation (handling datasets significantly larger than those seen during training). The authors suggest exposing the model to a wider range of dataset sizes during training.
  • Quadratic Scaling: The transformer architecture scales quadratically with the number of features and data points, posing a challenge for very large datasets. The paper suggests exploring scalable transformer alternatives like Mamba or Gated Linear Attention.
  • Synthetic Data Reliance: While GAMformer extrapolates well, its training is exclusively on synthetic data. Further research could investigate the impact of different synthetic data generation strategies or the potential for fine-tuning on real data.
  • Understanding Shape Function Differences: The authors note interesting differences in shape plots between GAMformer and EBMs for categorical variables and are investigating these further.

Summary updated

BibTeX
@inproceedings{mueller2024gamformer,
  author = {Andreas C Mueller and Julien Siems and Harsha Nori and Rich Caruana and Frank Hutter},
  title = {{GAMformer: Exploring In-Context Learning for Generalized Additive Models}},
  booktitle = {InterpretableAI @ NeurIPS},
  year = {2024},
  url = {https://openreview.net/forum?id=0HOHJuNpZl},
}
Figure