Market-Basket Rules

Directional A → B basket rules with confidence, lift, and support, mined live by one _relate per anchor category. No precomputed rule table, no Apriori batch job.

Market-Basket Rules: screenshot from the E-commerce demo
🛒 E-commerce_relateE-commerceCross-vertical
Production anchorTen anchor categories swept with one _relate each over the order history, rules kept when the lift's 95 % interval clears 1, then ranked by lift, in the Baskets section of the e-commerce demo's Patterns view. Dog dry food → dental treats leads at 3.17×, with 64 % confidence one way and 96 % the other.

The problem

Market-basket analysis is one of the oldest questions in retail data: when a basket holds A, how often does it also hold B? The classic answer is a batch job (Apriori, FP-growth) that writes a frozen rule table. The table is stale the day after it is built, and somebody has to own the job that rebuilds it.

The rules are also directional, which a plain co-occurrence count hides. The share of A baskets that also hold B is usually not the share of B baskets that also hold A, and a cross-sell or shelf decision depends on which way the rule points.

How it works

For each anchor category, one _relate over the orders whose basket contains the anchor returns the related categories with the counts behind the lift. Confidence (the share of anchor baskets that also hold B) and support come from the same counts. Rules whose lift interval clears 1 at 95 %, held across all the pairs tested, are ranked by lift, so the table is a query over the current orders rather than a stored artifact.

Pattern Explorer and Basket Rules are one view in the demo now: Patterns › Baskets sweeps the anchors and shows each rule's confidence in both directions and its support, and the anchor filter narrows it to the one anchor you pick.

For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application.

See it live

This use case runs in the 🛒 E-commerce demo today. Click through to the live application and inspect the queries that produce the result.

Open the live demo →