Menu Big Learning

Learning inside databases

Training data often begins in tables. Bringing a learning calculation close to those tables can spare a large export, but it also requires a way to express iteration and shared model state.

A bank of thin upright cards set into rows in a slotted wooden tray.
Records arranged in rows

From rows to training examples

Consider a table of ratings with a user, an item and a score in each row. A relational database can join those rows to item descriptions, select a time period and group observations by user. A training table is already the result of choices about missing rows, repeats and which information was available at prediction time.

Moving the full result into a separate program adds a transfer and produces a second copy that must stay consistent with the first. An in-database method keeps more of the work within the engine, where partitioning, joins and aggregation are already available.

A model inside the database
  1. Select examples
  2. Join features
  3. Aggregate updates
  4. Store model values

What a repeated computation needs

A SQL aggregate combines values from many rows. Training can use this pattern when a single pass over rows provides partial quantities that can be merged into an update. The next pass needs the updated model, so the system must also express a sequence of such computations.

The MADlib project described SQL-based algorithms for statistics and machine learning inside a database engine. Its research question included how to design reusable patterns for parallel computations. Avoiding an export is a practical benefit. A particular operation must still suit the database’s execution model to run efficiently.

How current is the training set?

A database can define which version of a table a query reads while other users change rows. A learning procedure needs a corresponding account of which observations and model values went into an update. Repeatable comparisons can become difficult if records change halfway through an experiment.

The 2013 workshop brought these questions to machine learning practitioners and database researchers together. In a recommendation problem, matrix factorization can infer user and item factors from a sparse set of ratings. Partitioning the table is only a beginning, because different partitions can still need to update the same item.

Further reading