How to Test an AI Demand Forecast Against Real Orders

Use eight weeks of real invoice data to see when a nearest-neighbor AI demand forecast beats a simple baseline and when it does not.

A shopkeeper with a tablet checks cartons against products on a storeroom shelf.
Invoices record units sold. A buyer planning replenishment also needs stock on hand, outstanding orders and supplier lead time.

An AI model can learn how sales vary across products and weeks, but a buyer needs to know how much faith to place in the next forecast. A practical first test is to compare it with numbers a buyer could have calculated before that week began. One ornament sold by a UK retailer shows why the choice of week matters.

What an invoice can tell a forecaster

The UCI Online Retail invoice dataset contains dated invoice lines. For stock code 85123A, a white hanging heart T-light holder, Yenra summed positive quantities on invoices other than cancellations. We used Monday-to-Sunday weeks, including days without a matching invoice as zero recorded units. These are gross positive invoiced units. They do not measure unmet demand, stock on hand or a customer's reason for buying.

A laptop with multiple graphs and charts on its screen is placed in an office setting.
Retain the stock code, unit and sales interval when comparing demand forecasts.

Which simple forecast came closer?

For the eight complete weeks ending October 16 through December 4, 2011, we compared the preceding week’s units with the mean of the preceding four weeks. Each forecast uses only information from earlier weeks. Their mean absolute errors were 613.38 units and 392.16 units, respectively. Yenra also tested a three-neighbor AI forecaster. It found the three earlier weeks whose preceding sales were closest to the current preceding week, then averaged the sales that followed those three examples. Only completed weeks were eligible, with recent examples winning ties. Its mean absolute error was 494.13 units, between the two baselines. In the week ending November 6, sales jumped to 1,704 and all three forecasts fell well short.

Weekly positive invoice quantities for stock code 85123A with three forecasts from earlier weeks.
Each dot covers one Monday through Sunday. Cancellations and nonpositive quantities are excluded. Open the full-size chart.

Download the observations and all three forecasts (CSV). The week-ending date is Sunday. The mean uses only the previous four complete weeks. Adapted from Daqing Chen’s Online Retail (2015), UCI Machine Learning Repository, CC BY 4.0. Yenra calculated the comparison forecasts.

A warehouse management system featuring multiple robotic arms and conveyor belts in an industrial or manufacturing environment.
A missing sale can reflect unavailable stock.

What a learned forecast would need to improve

The M5 competition organizers’ data, benchmarks and submissions provides a larger, separate benchmark for learned forecasts across retail products and aggregation levels. A more complex method could be tested by issuing its forecasts on the same dates and score the same item and unit. A buyer would then combine it with lead time, stock and the cost of excess or missed sales. A better weekly forecast alone does not prove better availability.

A man stands in front of a large display screen, likely in an office or industrial setting.
The inventory position combines on-hand stock with receipts and commitments.

The same order history can reveal which products a picker often collects together. How AI Uses Order Patterns to Make Warehouse Space More Useful

Try it with the evidence

Find the week where the average lost

Source notes. Actual positive invoiced units for the week ending December 4, 2011 were 726. The prior week predicted 898. The prior-four-week mean predicted 1,124.75. The eight-week mean absolute errors were 613.38 and 392.16 units, respectively. The three-neighbor forecast was about 1,712.67 units for December 4, with an eight-week mean absolute error of 494.13.

Prompt. Calculate the three absolute errors for December 4 and rank all three forecasts across eight weeks. Could an absent sale establish that nobody wanted the item?

Check your reading

The December 4 errors were 172 units for the prior week, 398.75 for the four-week mean and about 986.67 for the AI estimate. Across eight weeks the four-week mean ranked first, AI second and prior week third. Stockouts and absent demand can both leave a missing sale.

Illustrated field notes

Orders, stock and deliveries
Multiple computer monitors displaying various graphs and charts on a factory floor.
Supplier performance needs order-level promises and actual fulfillment dates.
A person is using a GPS navigation system or route optimization tool on an illuminated screen to plan their journey through a busy city.
A proposed route can change the replenishment lead time assumed by the buyer.
A person sitting at a desk in an office setting, surrounded by various objects and tools.
A customer inquiry can reveal demand absent from the sales ledger.
Risk, resources and visibility
A man examines a tablet displaying predictive maintenance data in an industrial setting.
A maintenance outage can temporarily change the available supply.
A man in a black suit jacket is intently analyzing data on multiple computer screens.
An unusual order requires review against its transaction and fulfillment record.
A large conference room with a long table and chairs, featuring maps, globes, and nautical-themed decorations.
Record when a disruption became known to the buyer.
A woman in a lab coat is intently focused on a computer screen displaying various graphs and charts.
Waste estimates need the quantities discarded as well as those ordered.