Exploring LLM Agents for Cleaning Tabular Machine Learning Datasets

Tommaso Bendinelli, Artur Dox, Christian Holz

TL;DR

This paper introduces a novel benchmarking framework to evaluate whether LLM agents can autonomously clean tabular training datasets to improve downstream machine learning model performance. Testing four state-of-the-art LLMs paired with a Python execution environment, the authors find that while LLMs excel at fixing row-level errors using contextual reasoning, they struggle to detect broader statistical anomalies like trends and distribution shifts across multiple rows.

What Problem Does This Paper Address?

Data cleaning is famously the most tedious and time-consuming part of a data scientist's job. Because data errors—such as sensor glitches, typos, and improper data merges—are highly dataset-dependent, automating this process has traditionally required rigid, hand-crafted rules or specialized machine learning tools that struggle with rare or complex error types.

While recent research has heavily focused on leveraging LLMs to automate feature engineering and model tuning, this paper shifts the spotlight back to data quality. The authors ask a fundamental question: If we keep the preprocessing and ML training pipeline completely fixed, can an LLM agent improve model performance purely by finding and fixing errors in the raw training data?

Methods

The authors design an iterative agent framework where the LLM is given an initial prompt ($P_0$) and access to two main tools:

  1. Interactive IPython Shell: Allows the LLM to write and execute Python code (using libraries like pandas) to inspect and programmatically modify the dirty dataset.
  2. Performance Evaluation Tool: A fixed, non-modifiable pipeline that trains an ML model on the LLM's modified training set and returns a performance score evaluated on a clean, held-out test set.

The agent operates in a multi-turn loop, using feedback from the evaluation tool and its own chat history to iteratively refine the dataset until a token budget is exhausted. The dataset yielding the highest performance score is selected as the final output. The authors also test the impact of providing "hints" (none, weak, or strong) in the initial prompt to see how guidance alters the agent's success.

Overview of the LLM data cleaning agent framework

Datasets

The framework was evaluated using three popular Kaggle datasets: Titanic, Meat Consumption, and Hotel Bookings. To establish a clear benchmark, the authors manually injected three types of systematic errors into the clean training data:

  • Numerical Shift: e.g., artificially inflating a feature value for a specific year.
  • NaN Corruption: Replacing valid entries with missing values based on specific conditions.
  • Categorical Shift: Changing categorical values to contextually inappropriate ones.

They also had two human data scientists attempt the same cleaning tasks within a 1-hour limit to establish a human baseline for comparison.

Key Insights and Ideas

  • Row-Level vs. Dataset-Wide Logic: LLMs are surprisingly good at using "common sense" row-level context. For instance, Claude 3.5 Sonnet successfully noticed that landlocked countries like Afghanistan shouldn't have massive fish consumption values. However, they completely failed to spot dataset-wide statistical shifts, such as a 10-day inflation bias applied only to the year 2016 in the Hotel Bookings dataset.
  • The Brute-Force Habit: Instead of performing deep exploratory data analysis (EDA), LLM agents frequently default to a trial-and-error approach, repeatedly saving and submitting minor dataset tweaks to the evaluation tool rather than writing code to understand the underlying distributions.
  • State Amnesia: With the exception of GPT-4o, most models struggled to leverage the persistent state of the IPython shell, often rewriting code from scratch in each turn rather than building incrementally on previous findings.
  • The Double-Edged Sword of Hints: Strong hints drastically improve performance, but weak hints can sometimes act as distractors, causing the LLM to apply inappropriate fixes that actually degrade model performance compared to providing no hint at all.

Key Results

  • Performance Gaps: No LLM reached the maximum potential performance of a perfectly cleaned dataset ($P_{Clean}$).
  • Dataset Difficulty: On the "easy" Titanic dataset, the best models (o3-mini and Claude 3.5 Sonnet) achieved a ~4-5% performance improvement, approaching the human baseline of 6.2%. On the "hard" Hotel Bookings dataset, all models achieved less than a 1% improvement (though human experts also achieved 0% within their 1-hour limit).
Performance improvement of LLM models vs. human baseline across datasets
  • Token Scaling: Performance gains follow a logarithmic trend of diminishing returns as token consumption increases. However, when Gemini 2.0 Flash Exp's token budget was expanded from 200k to 2 million tokens, its performance on the Titanic dataset jumped from 3.69% to 8.88%, showing that massive context windows allow for much more thorough error correction.
Impact of hints on LLM data cleaning performance

Limitations and Future Work

  • Text-Only Constraints: The current setup forces purely text-based interactions, preventing the LLM from viewing visual artifacts like histograms or boxplots, which are vital for human data scientists during data exploration.
  • Artificial Errors: The systematic errors were manually introduced by the authors, which limits the diversity and realism of the data corruption.
  • Future Directions: The authors suggest automating error generation to scale the benchmark, integrating multimodal capabilities so agents can interpret data plots, and developing methods to automatically diagnose whether an agent's failure occurred during the detection phase or the correction phase.

Summary updated

BibTeX
@inproceedings{bendinelli2025exploring,
  author = {Tommaso Bendinelli and Artur Dox and Christian Holz},
  title = {{Exploring LLM Agents for Cleaning Tabular Machine Learning Datasets}},
  booktitle = {FM-Wild @ ICLR},
  year = {2025},
  url = {https://openreview.net/forum?id=RXnQPYSoun},
}
Figure