Abstract
Feature engineering is one of the most important but most tedious tasks in data science. This work studies automation of feature learning from relational database. We first prove theoretically that finding the optimal features from relational data for predictive tasks is NP-hard. We propose an efficient rule-based approach based on heuristics and a deep neural network to automatically learn appropriate features from relational data. We benchmark our approaches in ensembles in past Kaggle competitions. Our new approach wins late medals and beats the state-of-the-art solutions with significant margins. To the best of our knowledge, this is the first time an automated data science system could win medals in Kaggle competitions with complex relational database.
Introduction: The "Black Art" of Feature Engineering
In modern data science, relational databases—structured as collections of interlinked tables—remain the primary storage format for industrial data. However, most machine learning algorithms, from linear regression to gradient boosting, require a single "flat" table as input. Bridging this gap requires feature engineering: the process of manually aggregating data across tables to create predictive variables.
This process is often described as a "black art." Data scientists frequently spend up to 95% of their project time hand-crafting features, such as "average transaction value over the last 30 days" or "total number of products purchased by a user." While automated tools like Deep Feature Synthesis (DFS) have emerged, they typically rely on fixed, pre-defined mathematical rules (e.g., SUM, MEAN, MAX). These methods often generate thousands of irrelevant features and fail to capture complex temporal or non-numerical patterns. The authors set out to move from rule-based generation to learned feature extraction.
The Relational Challenge
The fundamental difficulty of relational feature engineering stems from the structure of the data itself. A single row in a "main" table (e.g., a User) may be linked to dozens of rows in an "order" table, which in turn link to hundreds of rows in a "product" table.
The authors provide a theoretical foundation for this difficulty, proving that finding the optimal set of features through table joins is an NP-hard problem. This complexity necessitates the use of heuristics and learned representations rather than exhaustive search.
Proposed Method: Relational Recurrent Neural Networks (R2N)
To move beyond rule-based automation, the researchers developed the Relational Recurrent Neural Network (R2N). This architecture treats the relational schema as a tree structure and learns to aggregate information dynamically.
Relational Trees and Neural Aggregation
For any target entity, R2N constructs a relational tree by following foreign key paths. Instead of applying a static function like MEAN to aggregate child nodes into a parent, R2N employs a Recurrent Neural Network (RNN). The RNN processes the sequence of child nodes, learning a high-dimensional feature vector that best summarizes the underlying data for the specific predictive task.
Addressing Set Invariance
A significant challenge in using RNNs for database rows is that, unlike words in a sentence, rows in a table often have no inherent order. Standard RNNs are sensitive to input order. To ensure the model learns "set" functions (where the output is the same regardless of input order), the authors sort input vectors by their mean values before processing. This simple yet effective preprocessing step allows the RNN to approximate complex set operations like MIN or MAX more effectively.
Experimental Evaluation
The R2N framework was benchmarked against four diverse Kaggle competition datasets: KDD Cup 2014, Grupo Bimbo, Coupon Purchase, and Home Credit Default Risk. These datasets represent a variety of challenges, from recommendation systems to financial risk assessment.
The results demonstrate that R2N consistently outperforms rule-based systems like DFS. In head-to-head comparisons, R2N achieved higher Area Under the Curve (AUC) and Mean Average Precision (MAP) scores across all tasks where DFS was able to complete. More impressively, R2N achieved top-tier performance with minimal human intervention:
- KDD Cup 2014: Reached the top 8.8% (Silver medal tier).
- Coupon Purchase: Reached the top 6.3% (Bronze tier).
In the Home Credit competition, R2N's automated features were competitive with solutions produced by teams of experts working for months and writing tens of thousands of lines of code.
Discussion and Future Work
While R2N represents a major step toward fully automated data science, it introduces new trade-offs. The primary limitation is interpretability; unlike a "mean price" feature, R2N's neural embeddings are "black boxes," making them difficult to use in highly regulated industries like law or healthcare. Additionally, the computational cost is significant, often requiring days of training on high-end GPUs.
Future research directions include incorporating semantic knowledge—understanding the meaning of column names—to guide the heuristic path search more intelligently. There is also great potential in hybrid models that combine R2N’s relational learning capabilities with the raw predictive power of Gradient Boosting Machines (GBMs), which remain the industry standard for tabular data.
Summary updated