Skip to main content
When your data sits in several tables, you do not need to join them into one wide table first. You send the tables with their keys, and tabSutra reads them itself.

Describe the tables

Each table needs a name and its rows. It can also have:
  • a primary_key: a column whose values name the rows, each value once;
  • foreign_keys: columns that hold the primary key of a row of another table, written as {column: table};
  • a time_column: when the row happened.
The examples use the API, HEADERS and records set up in the Quickstart. For large tables, send files to /v1/databases-files instead, with one CSV or Parquet file per table. A table with a time column and foreign keys is read as a table of events: orders, visits, payments, comments. A table with a primary key and no time column is read as a table of things: customers, products, branches. A table of things may still have a time column, such as the date a customer signed up. A thing then exists only from that date on. The report of the database lists, for each table:
  • its kind;
  • its keys, with the share of foreign key values that were found in the table they point at;
  • the columns that will be read;
  • the text columns left out.
It also lists, for each table of things, which tables of events lead to it through one key or two. A low share of found keys usually means the key columns have different types, for example numbers in one table and strings in the other. You send the tables once. The database_id is then used for every prediction on the database. The same tables always give the same id.

Predict an answer per entity and date

A database prediction asks for one answer per row of one table at a date. The table is the entity table, such as customers. You give two sets of rows.
  • Examples have an entity, a date and a known answer. For example: customer C0012 on 1 May spent 1,250 in the 30 days after that date.
  • Rows to predict have an entity and a date.
window_days says that the answer is about the 30 days after the date. An example’s answer therefore counts as known 30 days after its date. If you would rather not build the examples yourself, describe the answer in words and let tabSutra build them. See Tasks described in words.

What a row reads

For an entity at a date, the model reads the entity’s own columns, the tables of things it points at, the events that relate to it, its own earlier examples once their answers are known, and the examples of other entities whose answers were known before the first date asked about. Everything it reads is dated strictly before the row’s date. A row of a table of things dated on or after that date is not read either.

Columns that hold the answer

Sometimes a table holds a column that is the answer, or is computed from it, such as a lifetime value that is updated every night. Leave such columns out with exclude_columns, written as "table.column".

Rows asked together

The prediction for one row can move a little with the other rows asked in the same call. This does not happen in tables. For results you can reproduce, ask for the same set of rows together.

Evaluate

/v1/databases/{database_id}/evaluate holds out the examples of the latest dates, about the share you ask for. It predicts them from the earlier ones, in the same way as a real prediction would be made on those dates.
Besides the usual baseline, the result has two simple rules that are hard to beat on some tasks:
  • the entity’s latest known answer;
  • the mean of its known answers.
If the model does not clearly beat them, the answer may depend mostly on the entity’s own past, and the rest of the database adds little.

Limits

  • Text, image and embedding columns of a database are read in the same way as in a table. See Inputs.
  • A database holds at most 50 million rows across its tables.
  • At least 8 examples dated before the first row to predict are needed.
  • The predictions are always returned in the answer’s own units.