Markdown Decisions

_estimate across discount levels picks the shallowest level that clears the overstock within a quarter, or says that no markdown will. In the demo's data it proposes none.

Markdown Decisions: screenshot from the E-commerce demo
🛒 E-commerce_estimateE-commerce
In the demoIn the e-commerce demo, the 15 largest overstock rows each get _estimate of units at 0–20 % off: 14 won't clear within 13 weeks at any level and one clears at full price, so no markdown is proposed.

The problem

Markdown decisions in retail are usually made by category managers who watch sell-through rates and intuit when to discount. The intuition is informed by experience but it is not statistical — the manager guesses at the right discount level, posts it, and hopes the recovered demand offsets the margin loss. Half the time the discount is too shallow and inventory still ages out; the other half it is too deep and margin is left on the table.

The data has the answer. Historical markdown events show how demand responded to each discount level for similar SKUs. For a given SKU at a given days-in-stock with a given on-hand quantity, the conditional expected demand at each discount tier is computable from prior events. The right discount is the one where predicted recovered margin × predicted demand exceeds the alternative of holding the inventory at full price.

How it works

_estimate is the operator for "predicted quantity at a query point." For each of the largest overstocked SKUs, the demo runs _estimate of next month's units_sold with the regression model at full price and at 5, 10, 15 and 20 % off. From the units follow the weeks the excess takes to sell. The proposal is the shallowest discount that clears the excess within 13 weeks: hold if full price already does, a markdown at the level that does, and "won't clear" when no level does, instead of proposing the deepest cut.

In the PetNord data the sweep proposes no markdown: of the 15 largest overstock rows, 14 won't clear at any level and one clears at full price. A markdown is the wrong tool for that stock, and the view says so. The horizon and the deepest level are application-level settings, and a deployment can route a proposal to the category manager rather than post it automatically.

{
  "from": "monthly_sales",
  "where": {
    "product_sku": "SKU-PT-0061",
    "units_last_month": 3,
    "pet_type": "dog",
    "category": "dry-food",
    "brand": "Acana",
    "season": "spring",
    "price_eur": 69.5
  },
  "estimate": "units_sold",
  "select": [
    "estimate"
  ],
  "model": "regression"
}

For the full architecture, see the technology overview. For the broader narrative across multiple use cases, read The Predictive Application. For the whole picture, see predictive e-commerce.

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 →

Build it with Claude Code

Paste this prompt into Claude Code, or another coding agent, in your own codebase. It runs Aito locally from the Docker image, reads the API docs written for agents, and follows a working reference implementation.

Discount decisions: a prompt for Claude Code
Add discount decisions to this codebase using Aito, a predictive database. The feature: show, for a product, what a given discount would do to expected sales and margin, from our sales history, and flag prices outside the fair band.

1. Run Aito locally: `docker pull ghcr.io/aitohq/aito`, then follow https://aito.ai/docker/ to start it with your own API keys (keep them in the environment, never in code).
2. Read https://aito.ai/docs/api/llms.txt for the v2 query shapes before writing any query.
3. Read the use-case guide: https://aito.ai/use-cases/markdown-decisions/
4. Use this reference implementation as the pattern (schema, data load and queries): https://github.com/AitoDotAI/aito-ecommerce-demo/blob/main/src/discount_what_if.py and https://github.com/AitoDotAI/aito-ecommerce-demo/blob/main/src/price_bands.py
5. Find the matching tables in this codebase, design the Aito schema for them (links between tables where we have foreign keys), and load a sample.
6. Check the numbers before building the view: compare a few of them against a direct count over the same rows (SQL or a short script), and report any that differ.
7. In the UI, show the evidence behind each number (the counts, the interval or $why), and leave out patterns with too little data behind them.

Ask me before changing anything outside the new feature.

Frequently asked

How does this compare to dedicated markdown optimization SaaS?

Dedicated tools optimize for accuracy on a specific time-series shape (seasonal apparel, perishables, etc.). _estimate is more general — works across product categories without per-category tuning. A dedicated tool may win on margin in its target category; the general approach trades that for broad applicability across the catalog without separate model maintenance per category.

What about cross-product effects (markdown one SKU, demand for sibling SKUs shifts)?

The query can include sibling-SKU markdown state in the where clause to condition on it. The conditional probability reflects the cross-product effect to the extent that historical events show it. For deeper modeling of substitution effects, the application can run multiple _estimate queries (one per markdown scenario) and pick the joint maximum.

How does this handle promotional events (sale weekends, holidays)?

Add the event flag to the where clause; the conditional probability conditions on it. Historical Black Friday markdowns inform future Black Friday markdowns automatically. For new events without history, the prediction returns lower confidence — the system honestly says it has not seen this combination before.

Can it predict optimal markdown depth for never-discounted SKUs?

SKUs with no markdown history return low confidence. The system can infer through similarity (similar SKU, similar category, similar customer segment) but with a wider confidence band. The category manager gets a suggested range, not a single answer; the manager makes the call on first markdown.

How does this integrate with our pricing or inventory system?

Aito returns the prediction as JSON; the pricing system reads the predicted optimal discount and either applies it or surfaces for review. Most deployments wire this through the existing pricing pipeline: the inventory system queries Aito for the recommendation, the pricing system applies it (or surfaces). The integration is HTTP and JSON.