Introduction
Feature engineering remains a cornerstone of successful machine learning, often serving as the decisive factor in model performance. Despite its importance, the process is frequently fragmented into two distinct phases: feature generation and feature selection. Feature generation involves creating new dimensions through mathematical transformations, while feature selection aims to prune redundant or noisy variables.
This disjointed approach often leads to sub-optimal results. Generation can create an explosion of redundant features that overwhelm the model, while premature selection might discard "weak" features that only reveal their predictive power when combined non-linearly with others. To address this "Goldilocks" problem, researchers have introduced MAGS (Multi-Agent System with Long and Short-Term Memory), a framework that treats feature engineering as a collaborative "teaming" exercise between Large Language Model (LLM) agents.
The MAGS Framework: Unifying Selection and Generation
The core philosophy of MAGS is the unification of selection and generation into a single, iterative process. By allowing a system to strategically decide when to expand the feature space and when to contract it, MAGS navigates the vast search space of possible feature combinations more effectively than traditional automated feature engineering (AFE) tools.
As illustrated in the figure above, traditional selection might discard Feature 1 ($f_1$) because it performs poorly in isolation. However, a unified approach recognizes that while $f_1$ is "bad" alone, its interaction with Feature 3 ($f_1 * f_3$) might be highly informative. MAGS enables this nuanced reasoning by employing three specialized agents:
- The Router Agent: Acting as the project manager, the Router analyzes the current state of the feature set and decides whether the next logical step is generation or selection.
- The Generator Agent: This agent applies mathematical operators (e.g., $log$, $square$, or binary operations) to create new features.
- The Selector Agent: Serving as the editor, the Selector evaluates feature relevance and eliminates redundant dimensions to maintain model efficiency.
System Architecture and Technical Innovations
The MAGS architecture is built upon several key technical innovations that allow LLMs to perform complex mathematical reasoning and long-term planning.
Feature Sets as Token Sequences
To bridge the gap between natural language processing and mathematical transformation, MAGS represents features using postfix notation. For example, the interaction $f_1 * f_2$ is represented as the sequence $f_1 f_2 *$. This format allows the LLM agents to treat feature engineering as a sequence generation task, leveraging their inherent strengths in pattern recognition.
Dual-Memory Mechanism
A critical challenge in agentic workflows is preventing the system from getting stuck in local optima or "drifting" away from the goal. MAGS solves this with a two-tiered memory system:
- Short-Term Memory: This tracks the optimization trajectory within a single iteration, providing immediate feedback on recent actions.
- Long-Term Memory: This stores high-quality historical feature sets (excellent demonstrations). By referencing these "best-of" examples, the agents can maintain a global perspective on the search space.
Reinforcement Learning for Strategic Planning
The Router agent is not a static script; it is fine-tuned using Offline Proximal Policy Optimization (PPO). By training on historical performance data (Performance $p$ resulting from Action $a$ in State $s$), the Router learns dataset-specific strategies. For instance, it might learn to prioritize generation for low-dimensional datasets and aggressive selection for noisy, high-dimensional ones.
Experimental Evaluation
The researchers evaluated MAGS across six diverse datasets from LibSVM, UCIrvine, and OpenML, covering both classification and regression tasks. The datasets ranged from 19 to 50 initial features.
Key Results and Performance
MAGS achieved state-of-the-art (SOTA) performance across all tested datasets, outperforming 12 competitive baselines, including specialized tools like TTG (generation) and LASSO (selection).
- Robustness: The features generated by MAGS were tested across six different downstream models (Random Forest, SVM, KNN, etc.). The performance gains were consistent; notably, MAGS boosted KNN accuracy on the
messidordataset by 5.4% compared to the best baseline. - Efficiency: In a case study on the
openml_586dataset, MAGS demonstrated its balancing act by generating 4 high-value features while simultaneously pruning 20 redundant ones. This resulted in a leaner, more interpretable, and more accurate representation than tools that only perform one of those functions.
Discussion and Limitations
While MAGS represents a significant step forward in automated feature engineering, several challenges remain. The reliance on multiple LLM calls makes the process computationally expensive and slower than purely algorithmic methods. Furthermore, the context window limits of current LLMs may hinder scalability to datasets with thousands of features.
Future work will likely focus on more efficient agent architectures, such as using smaller, specialized models for the Generator and Selector, and extending the framework to handle multi-task or transfer learning scenarios where features must remain robust across changing data distributions.
Summary updated