Skip to main content
A retailer’s data usually sits in a few tables: customers, products, orders, and sometimes returns, visits or reviews. This page shows three common questions on such a database. None of them needs a hand-built feature table.
For the business side of this problem, and how it compares with classic machine learning, read the case study on our website: Churn, spend and next purchase from an order database.

The tables

The returns table points at orders, and each order points at a customer. So a return reaches its customer through two keys. The database report lists this path under events_reaching.

Spend in the next 30 days

Many customers spend nothing in a given month, and a few spend a lot. The median of the predicted distribution is then often zero, while the mean is above it. Use the mean when you need totals, such as a revenue forecast for a region, because means add up and medians do not. Use the quantiles when you need to know how uncertain a single customer’s spend is.

Churn in the next 30 days

rows: active limits the question to customers who ordered in the 30 days before the date. Asking whether a customer who has not ordered for a year will order nothing next month gives answers that are true but of little use. The definition of churn matters more than the model. “No order in the next 30 days” suits a grocery business. A furniture retailer may need a window of a year. Try a few windows with tasks/evaluate and look at what each one predicts before you choose.

Products a customer will buy next

If the product table has a name or description column, its words help find items similar to what the customer bought before. Check the result with tasks/evaluate on the same task. Compare ours with rule_past_filled. That rule recommends what the customer bought before, then the most popular items. In some businesses, such as groceries, people mostly buy the same things again, and this rule is hard to beat. In others, such as books, they rarely buy the same item twice, and the rule does poorly.

Standing at a past date

Each of the calls above takes at. With "at": "2026-03-01", the model uses only what was known on 1 March 2026. You can run the three questions at a few past dates and compare the predictions with what happened afterwards. This is a fair test of the setup before you use it.