API, HEADERS and records set up in the Quickstart.
The settings
You can use any of them on its own. A table with only a
time_column is a table of dated records, such as daily transactions. A table with only a group_column is a table of groups without time, such as the employees of companies. If rows have an order but no dates, give each row its position in the group as a number in the time_column.
What the model does with them
With atime_column, a row to predict reads only the context answers known strictly before the row’s own values were known. A context answer counts as known from the row’s time plus target_delay_days.
The time_column is also read as an input. Every other date column is read relative to the row’s time.
With a group_column, a row also reads the other rows of its group. With a time_column as well, it reads only the earlier ones and never the later ones. The group column is not read as a feature itself.
An example: monthly account snapshots
account_months.csv
recovered_next_month is the amount recovered during the month after the row, as a share of the original amount due. It is known at the end of that following month, about 31 days after the row’s date.
AC1042 has no answer yet, so it is not a context row. You send it to /v1/predict.
Send the open rows of a group together
The rows of a group are predicted together, and they read each other in time order. If a group has more than one row without a known answer, send all of those rows in the same/v1/predict call. Otherwise the later row cannot read the earlier one.
In the example above, with a delay of 31 days, the rows of the last month are always open. With a longer delay, several months per account are open at once, and all of them go in the same call.
Group answers
Sometimes the group itself has an answer. An account’s total recovery is known once the account is closed. A delivery route’s total time is known once the route is finished. Put that answer in a column, on any or all of the group’s rows, and name it asgroup_target. Leave the column empty while the group is still open.
target_delay_days after the group’s last row. Every row you predict then carries two predictions: the row’s own answer, and the group’s answer as of that row’s time. At least four groups with a known answer are needed.
A group must have one answer. If two rows of a group give different values, the call stops with the error group_target_varies.
Values known before the row’s time
Sometimes a row’s values are fixed before the row happens. The stops of a delivery route are planned when it sets off, and an instalment schedule is fixed when the loan is signed. Put the date the values were fixed in a column and name it asknown_column. The model then reads each such row as of that date. It does not read answers that came between that date and the row’s own time.
Evaluate
With atime_column, /v1/evaluate holds out the latest rows by the time they were known. Each held-out row is predicted from what was known before it. With a group_column and no time column, it holds out whole groups instead, chosen by the group’s name.
Backtest at a past date
/v1/fill with as_of stands at a past date. It uses only what was known on that date, and it predicts the rows whose answer came on or after it. Rows known after the date are left out.
as_of does not change these predictions. You can compare them with what happened afterwards.
Things to check
- The fit report has a
historysection. It shows the time range, the number of groups, the largest group and the number of groups with a known answer. A very large group is slower to read. - Date rows by when their values became known. See Time and leakage.
- A row without a date is left out of the context, and a row without a date cannot be predicted.