General-purpose Declarative Inductive Programming with Domain-Specific Background Knowledge for Data Wrangling Automation

Lidia Contreras Ochando, Cèsar Ferri, José Hernández-Orallo, Fernando Martínez-Plumed, María José Ramírez-Quintana, Susumu KatayamaarXiv 2018

This paper, presented at the intersection of machine learning and software engineering, explores how to make "data wrangling"—the often-painful process of cleaning and reformatting data—as intuitive for machines as it is for humans.

TL;DR

By combining general-purpose Inductive Programming (IP) with modular, domain-specific background knowledge, the authors demonstrate a system that can automate complex data transformations from just a single example. This approach outperforms specialized tools like Excel’s FlashFill, particularly when dealing with inconsistent data formats.

What Problem Does This Paper Address?

Data scientists famously spend up to 80% of their time on data wrangling. While tools like Excel's FlashFill have made strides in automating string transformations, they often hit a wall when the data is semantically complex.

For example, if a column contains dates in multiple formats (e.g., "25-03-74" and "03/29/86"), a standard string-manipulation tool might fail to realize that "25" and "29" both represent the "day" component. Humans solve this easily because we have background knowledge: we know what a date is and how its components behave. The challenge is giving machines that same context without making the search for a solution mathematically impossible.

Methods

The authors utilize Inductive Programming (IP), specifically a system called MagicHaskeller. Unlike typical machine learning that requires thousands of rows, IP aims to synthesize a declarative program (in this case, Haskell code) from just one or two input-output examples.

The core innovation is Domain-Specific Induction (DSI). Instead of searching through a massive library of every possible function (which leads to a combinatorial explosion), the system uses modular Domain-Specific Background Knowledge (DSBK) files.

The process works as follows:

  1. Identify the Domain: The user suggests the data type (e.g., Dates, Emails, Phones).
  2. Load DSBK: The system loads a curated library of Haskell functions relevant to that domain.
  3. Synthesize: Using one example (e.g., "8/17/2017" $\rightarrow$ "17th of August"), the IP engine searches for a combination of functions that satisfies the transformation.
  4. Execute: The resulting program is applied to the rest of the dataset.
Figure 1: Automating data wrangling with IP: process example. The first row (Data and Output) is used as a input predicate for the IP system. The function returned using the correct domain is applied to the rest of the instances to obtain the outputs.

Datasets

The authors noted a significant gap in the field: there was no public, reusable benchmark for data wrangling. To fix this, they introduced a new Data Wrangling Benchmark consisting of 32 datasets across six domains:

  • Freetext: General string manipulation.
  • Dates/Times: Handling various formats and time zones.
  • Names: Extracting initials or honorifics.
  • Emails/Phones: Parsing components and adding prefixes.
  • Units: Converting between measurement systems (e.g., cl to liters).

This benchmark is now publicly available for the research community.

Key Insights and Ideas

  • The Breadth-Depth Trade-off: The computational complexity of finding a program is $O(b^d)$, where $b$ is the number of available functions (breadth) and $d$ is the number of functions combined to solve the problem (depth). By using DSBK, the authors keep $b$ small, allowing the system to find deeper, more sophisticated solutions within a reasonable timeframe.
  • Semantic vs. Syntactic: Most wrangling tools are syntactic (looking at characters). DSI is semantic; it understands that "August" and "08" are the same entity. This allows it to handle "dirty" columns where formats change row-by-row.
  • Extensibility: Because the system uses a general-purpose language (Haskell), users can easily add new domains by simply writing a few helper functions in a text file.

Key Results

The DSI approach was compared against the "default" IP library and Microsoft’s FlashFill.

  • Accuracy: DSI achieved 100% accuracy on many complex tasks where FlashFill failed. For instance, in extracting the day from a list of dates with wildly different formats, DSI succeeded with a single example, whereas string-based systems produced errors for any row that didn't perfectly match the format of the first example.
  • Efficiency: As shown in the training time analysis, keeping the breadth ($b$) low is critical. When all domain libraries were combined into one massive "all" library, the system often timed out (120s limit) because the search space became too vast.
Training time grows exponentially with the maximum depth (dmax) and the number of primitives (b).

Limitations and Future Work

The primary limitation is that the user currently has to manually specify the domain (e.g., "this is a phone number column"). The authors acknowledge that for a truly "hands-off" experience, the system needs to automatically detect the domain.

Future work plans include:

  • Developing a meta-model to suggest the appropriate DSBK based on the features of the input data.
  • Integrating the engine into a standalone tool or API that can be used by non-programmers.
  • Expanding the benchmark with even more diverse real-world data challenges.

Summary updated

BibTeX
@misc{ochando2018general,
  author = {Lidia Contreras Ochando and Cèsar Ferri and José Hernández-Orallo and Fernando Martínez-Plumed and María José Ramírez-Quintana and Susumu Katayama},
  title = {{General-purpose Declarative Inductive Programming with Domain-Specific Background Knowledge for Data Wrangling Automation}},
  year = {2018},
  eprint = {1809.10054},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1809.10054},
}
Figure