Learning a Decision Tree Algorithm with Transformers

Yufan Zhuang, Liyuan Liu, Chandan Singh, Jingbo Shang, Jianfeng Gao

Abstract

Decision trees are renowned for their ability to achieve high predictive performance while remaining interpretable, especially on tabular data. Traditionally, they are constructed through recursive algorithms, where they partition the data at every node in a tree. However, identifying a good partition is challenging, as decision trees optimized for local segments may not yield global generalization. To address this, we introduce MetaTree, a transformer-based model trained via meta-learning to directly produce strong decision trees. Specifically, we fit both greedy decision trees and globally optimized decision trees on a large number of datasets, and train MetaTree to produce only the trees that achieve strong generalization performance. This training enables MetaTree to emulate these algorithms and intelligently adapt its strategy according to the context, thereby achieving superior generalization performance.

Introduction

Decision trees have long been a cornerstone of tabular machine learning due to their interpretability and speed. However, traditional induction methods face a fundamental trade-off. Greedy algorithms like CART are computationally efficient but often short-sighted, making local splits that may not be globally optimal. Conversely, global optimizers like GOSDT seek mathematical optimality on training data but are computationally expensive (NP-hard) and prone to overfitting.

MetaTree addresses this by treating decision tree induction as a meta-learning task. Instead of relying on a hard-coded heuristic, MetaTree uses a Transformer-based architecture to learn the "algorithm" itself, producing splits that prioritize generalization over simple training-set optimization.

Methods and Architecture

MetaTree operates as a recursive inference engine. Given a dataset, it outputs a single split (feature and threshold), partitions the data, and is called again on the resulting subsets until a target depth is reached.

Overview of the MetaTree framework, including the recursive generation process, transformer architecture, and two-phase learning curriculum.

The model utilizes a LLaMA-style Transformer backbone enhanced with Tabular Attention. This mechanism alternates between row-wise and column-wise attention, reducing the computational complexity from $O(n^2 m^2)$ to $O(n^2 + m^2)$, making it feasible for tabular data.

The training follows a Two-Phase Learning Curriculum:

  1. Phase 1 (Imitation): The model learns the mechanics of tree building by mimicking GOSDT.
  2. Phase 2 (Generalization): The model is presented with splits from both GOSDT and CART and is trained to select the split that yields the highest validation accuracy. This teaches the model to ignore "perfect" training splits that fail to generalize.

Key Results and Insights

MetaTree was evaluated on 91 real-world datasets that were entirely held out during its training on 10.8 million trees. The results demonstrate that MetaTree consistently outperforms traditional heuristics and global optimizers.

Generalization accuracy of MetaTree compared to traditional decision tree algorithms across various tree depths and datasets.

Superior Generalization

Across the benchmark datasets, MetaTree achieved the highest average rank (1.34) compared to GOSDT (2.68) and CART (3.30). It proved to be the top performer on 72 out of 91 datasets for depth-2 trees. Notably, MetaTree exhibits "look-ahead" behavior, successfully solving XOR-style problems that stymie greedy algorithms.

Zero-Shot Depth Generalization

While MetaTree was trained only on trees of depth 2, its recursive nature allows it to generate high-quality trees of depth 3 and 4 without additional training. This zero-shot capability highlights the robustness of the learned splitting strategy.

Efficiency and Robustness

MetaTree produces splits in milliseconds with constant memory usage, whereas global optimizers like GOSDT often encounter out-of-memory (OOM) errors or significant latency as tree depth increases. Furthermore, bias-variance decomposition shows that MetaTree has lower empirical variance than traditional methods, indicating greater stability across different training samples.

Conclusion

MetaTree represents a shift from manually designed heuristics to learned algorithmic strategies for decision tree induction. By leveraging the representational power of Transformers and a meta-learning curriculum, it bridges the gap between greedy efficiency and global optimality. Future work aims to scale MetaTree to handle larger feature sets and integrate it into larger AI systems as a differentiable, interpretable reasoning component.

Summary updated

BibTeX
@article{zhuang2024learning,
  author = {Yufan Zhuang and Liyuan Liu and Chandan Singh and Jingbo Shang and Jianfeng Gao},
  title = {{Learning a Decision Tree Algorithm with Transformers}},
  journal = {Accepted by TMLR},
  year = {2024},
  url = {https://openreview.net/forum?id=1Kzzm22usl},
}
Figure