Not Another Imputation Method: A Transformer-based Model for Missing Values in Tabular Datasets

Camillo Maria Caruso, Paolo Soda, Valerio GuarrasiarXiv 2024 · DOI

TL;DR

NAIM (Not Another Imputation Method) is a novel transformer-based model that handles missing values in tabular data without needing to fill them in first. By using specialized feature embeddings and a modified "double-masked" self-attention mechanism, NAIM learns directly from available data, outperforming traditional machine learning and deep learning models in both accuracy and robustness.

What Problem Does This Paper Address?

In the world of tabular data—think spreadsheets with rows of samples and columns of features—missing values are an unavoidable headache. Whether due to human error, sensor failure, or privacy concerns, gaps in data can break standard AI models.

The traditional solution is imputation: using an algorithm to "guess" the missing values (e.g., filling a blank with the average value of that column). However, imputation is a double-edged sword; it can introduce bias, noise, or false patterns that lead to unreliable predictions. While some tree-based models (like XGBoost) can handle missing data intrinsically, most deep learning architectures still struggle. The authors of this paper set out to build a transformer model that doesn't just "deal" with missing data but thrives by ignoring it entirely.

Methods

The authors introduce NAIM, an encoder-only transformer architecture specifically optimized for incomplete tabular datasets. Its success hinges on three key innovations:

  1. Feature-Specific Embeddings: Instead of a single flat vector, NAIM treats each feature (categorical or numerical) as a separate entity. For missing values, it uses a special "padding index" associated with a non-trainable zero vector. This ensures that a missing value doesn't accidentally pull the model toward a "mean" or "default" value. The NAIM architecture uses a specialized embedding block to handle categorical and numerical features separately.
Figure 1: The architecture of NAIM, composed of the Feature Embedding, the Encoder equipped with the Masked Multi-Head Attention mechanism, and the final classification head [13].
  1. Modified Masked Self-Attention: Standard attention mechanisms in NLP mask out future words. NAIM introduces a "double-masking" approach. It masks both the rows and columns of the attention matrix corresponding to missing features. This ensures that missing data contributes exactly zero to the final representation of a sample. The proposed double-masking ensures that missing features (shown in gray) are completely isolated from the attention calculation.
The proposed double-masking ensures that missing features (shown in gray) are completely isolated from the attention calculation.
  1. Missing Data Regularization: This is the "secret sauce" for generalization. During training, the model randomly masks out additional features even if they are present. This forces the model to learn multiple redundant pathways to reach a correct prediction, making it incredibly resilient when data is missing during real-world testing. The regularization strategy randomly masks features during training to simulate incomplete data scenarios.
The regularization strategy randomly masks features during training to simulate incomplete data scenarios.

Datasets

The researchers evaluated NAIM on five diverse, publicly available classification datasets from the UCI repository:

  • Adult: Income prediction.
  • BankMarketing: Predicting term deposit subscriptions.
  • OnlineShoppers: Predicting purchase intent.
  • SeismicBumps: Predicting seismic hazards in mines.
  • Spambase: Email spam detection.

To test robustness, they artificially introduced "Missing Completely At Random" (MCAR) values at rates ranging from 0% to 75% in both the training and testing sets.

Key Insights and Ideas

  • Imputation is Optional: The biggest "aha" moment is that deep learning models don't need a complete grid to work. By isolating missing features at the attention level, the model focuses only on the high-quality information that actually exists.
  • The Robustness Gap: Most models perform well if they see the same amount of missing data in training and testing. However, they usually fail if they are trained on "perfect" data but encounter "messy" data in the real world. NAIM’s regularization technique bridges this gap, maintaining high performance even when 75% of test data is missing.
  • Double Masking is Essential: The authors demonstrate that standard transformer masking (which only masks columns) still allows "ghost" contributions from missing features to leak into the calculations. Their row-and-column masking is a cleaner, more mathematically sound approach for tabular data.

Key Results

NAIM was benchmarked against 11 unique models (including XGBoost, Random Forest, and TabNet) paired with three different imputation strategies (Mean, KNN, and MICE).

  • Win Rate: NAIM achieved statistically superior performance in 58.7% of the experimental scenarios.
  • Loss Rate: It performed worse than competitors in only 1.6% of cases.
  • Resilience: In the most extreme test (0% missing in training, 75% missing in testing), NAIM maintained significantly higher AUC (Area Under the Curve) scores than traditional machine learning models, which saw their performance plummet.

Limitations and Future Work

While NAIM is a powerful step forward, the authors note several areas for growth:

  • Computational Cost: Like all transformers, NAIM is more computationally expensive than simple decision trees. Future work will look into more efficient attention formulations.
  • Multimodal Data: The authors plan to extend NAIM to handle "missing modalities"—for example, a medical model that can still function if a patient has a blood test (tabular) but is missing an X-ray (image).
  • Interpretability: While transformers are often "black boxes," the authors want to use NAIM’s attention weights to help users understand which features the model is relying on when others are missing.

Summary updated

BibTeX
@misc{caruso2024not,
  author = {Camillo Maria Caruso and Paolo Soda and Valerio Guarrasi},
  title = {{Not Another Imputation Method: A Transformer-based Model for Missing Values in Tabular Datasets}},
  year = {2024},
  eprint = {2407.11540},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2407.11540},
}
Figure