Book a free call

Machine Learning in Retail: Where It Works, and Where to Start

Machine learning helps retailers predict demand, personalise offers and cut waste, but only when the data behind it is clean. Here is where it works in retail.

Hertiv engineering teamReviewed by a senior engineer
8 min read
Machine Learning in Retail: Where It Works, and Where to Start
On this page

Short answer

Machine learning in retail is the use of models trained on sales, customer and stock data to predict demand, personalise offers, set prices and reduce waste. It works best where a retailer already records clean, repeated data and where a small improvement in a forecast or a recommendation is worth real money.

What is machine learning in retail?

Machine learning in retail is the use of statistical models that learn from a shop's own data to make predictions and decisions, such as which products a customer is likely to buy, how much stock a store will need next week, or which price is most likely to sell. The model is trained on past sales, stock levels, prices and customer behaviour, then applied to new data as it arrives.

It differs from a fixed rule. A rule says that a product on promotion sells more; a model learns how much more, for which stores, at which price, and how that changes with the season. The model is only as good as the data it learns from, so retailers with messy stock records or missing sales history get poor results no matter which tool they buy.

Most retail machine learning falls into a few kinds of work: predicting what will sell, grouping customers by behaviour, recommending products, spotting unusual transactions, and reading text and images such as reviews or shelf photos. A team that starts with one of these, on data it already trusts, learns faster than a team that tries to cover all of them at once.

How does machine learning work in a shop?

Machine learning works in a shop by turning the records a retailer already keeps into a training set, then using the trained model to score new situations every day. Sales, stock movements, prices, promotions and customer visits are collected into one place, cleaned, and used to train a model that predicts the outcome the team cares about.

Data sourceWhat it recordsWhat it feeds
Point-of-sale recordsWhat sold, when, at what priceDemand and price models
Stock and warehouse systemsLevels, deliveries, lossesReplenishment and waste models
Loyalty and online accountsWho bought what, how oftenRecommendations and grouping
Website and app logsSearches, views, abandoned cartsProduct ranking and search
Supplier and weather dataCosts, lead times, seasonsForecasts that include outside factors

The model is then checked against data it has not seen before, so the team can see how far its predictions are from reality before it is used. Once it is live, the team watches the same gap every week, because buying habits change and a model trained on last year can drift. When the gap grows, the model is retrained on newer data.

Which retail use cases pay off first?

The retail use cases that pay off first are the ones where a small gain in accuracy is worth money every day and where the result is easy to measure. Demand forecasting and replenishment usually come first, because ordering too much ties up cash and ordering too little loses sales, and both are visible in the weekly numbers.

Use caseWhat the model doesHow the gain shows
Demand forecastingPredicts sales per product and storeLess stock held, fewer empty shelves
Product recommendationsSuggests items a customer is likely to buyMore items per order
Dynamic pricingTests prices against demandMargin on slow lines without losing volume
Fraud and returns checksFlags unusual orders or returnsFewer losses, fewer blocked good orders
Shelf and image checksReads shelf photos for gapsFaster restocking, fewer missed sales

Recommendations usually follow forecasting, because they need the same clean sales and customer records. Pricing comes later, since it needs careful testing: a wrong price is visible to every customer, so teams test changes on a small set of products first and compare the result with a matched set that did not change.

Recommendations and pricing

Recommendations work by finding patterns in what customers buy together and what similar customers have bought, then ranking those suggestions for each shopper. On a website this shows as related products or a personalised home page; in a store app it can be an offer tied to a loyalty account. The measure is simple: whether the suggested items are bought more often than items shown at random.

The hard part is new customers and new products, where there is no history to learn from. Teams handle this by falling back to popular items, by using product details such as category and price, and by asking the customer a few questions at the start. A recommendation that only repeats the best sellers adds little, so the team should check that it also surfaces items the customer would not have found alone.

Pricing models work in a similar way, learning how sales respond to price changes for each product group. They are most useful for clearing slow stock and for seasonal lines, where a small cut can move a lot of units. They are least useful for staple goods where customers notice the price and where a change can damage trust. For pricing help, the predictive analytics page covers how forecasts feed into commercial decisions.

Inventory, demand and waste

Inventory is where machine learning most often pays for itself in retail, because stock is cash sitting on a shelf. A model that predicts demand per store and per product lets a retailer order closer to what will actually sell, which cuts both the money tied up in stock and the sales lost to empty shelves.

Fresh food is the sharpest case. A model that overestimates demand for milk or bread creates waste that is thrown away; one that underestimates it creates empty shelves and lost sales. Teams measure both errors separately, because cutting waste by ordering less is only a gain if sales do not fall by more.

The model usually includes the day of the week, promotions, local events and the weather, since all of these move demand in ways a simple average misses. A forecast that ignores a local event will look wrong on the day it matters most, which is why teams check the inputs as well as the output.

Warehouse work benefits too. Models can predict which products will be picked together, so they can be stored near each other, and which deliveries are likely to arrive late, so the team can plan around them. These gains are smaller than the stock gain, but they add up across a large warehouse.

Example (hypothetical): a grocery chain cuts waste

Example (hypothetical): a grocery chain with 40 stores sells fresh bread. Each store orders 200 loaves a day on a fixed rule, sells 170 on average, and throws away 30. Across 40 stores that is 1,200 loaves wasted every day, and on some days a store also runs out before closing.

The team trains a model on past sales, the day of the week, promotions and the weather. It predicts demand per store, and the stores order to that prediction plus a small buffer of 5 loaves. Average waste falls from 30 loaves per store to 12, which is 18 fewer per store, or 720 loaves a day across the chain. Stock-outs fall too, because the prediction is higher than the old rule on busy days.

The numbers are invented to show the arithmetic, not a real project. The point is that the gain comes from ordering to a per-store prediction instead of a single fixed number, and it only holds if the sales data is recorded correctly and the model is checked every week.

Common mistakes with retail machine learning

The most common mistakes with retail machine learning start with the data. A model trained on sales records that miss online orders, or on stock counts that are weeks out of date, will make confident predictions that are wrong in ways the team cannot see until the shelves are empty or full.

  • Training on dirty data. Missing promotions, wrong product codes and unrecorded price changes all teach the model the wrong lesson.
  • Measuring the wrong thing. A forecast can look accurate on average while being wrong on the few products that matter most.
  • Letting the model run without review. Buying habits change after a promotion, a new competitor or a season, and a model that is never retrained drifts.
  • Automating prices without limits. A model with no guardrails can raise a price on a staple or cut it on a premium line before anyone notices.
  • Expecting a tool to fix the process. If nobody owns the forecast and nobody acts on it, the model changes nothing.

Each of these is a process failure, not a model failure. The teams that get value treat the model as one part of a weekly routine of checking, retraining and acting on the numbers.

How to start with machine learning in retail

Start with machine learning in retail by picking one use case, one data set and one measure of success, then running a short trial against the current way of working. Demand forecasting for a small set of products is a common first pick, because the result is easy to compare with what the team already does.

  1. Pick the use case. Choose one where a better prediction is worth money and where the result can be measured in weeks.
  2. Check the data. Confirm that sales, stock and price records are complete and correctly labelled for the products in scope.
  3. Set a baseline. Record how the current rule performs, so the model has something to beat.
  4. Run a trial. Use the model for a small set of stores or products and compare the outcome with a matched set that did not change.
  5. Decide on the numbers. Expand only if the trial beats the baseline on the measure that matters, such as waste, stock-outs or margin.

If the trial works, the next step is usually to widen the product set, then to add recommendations or pricing on the same data. Teams that need help scoping that first trial can start with machine learning development support, which covers data checks, a first model and the trial design.

Key takeaways

  • Retail machine learning learns from a shop's own sales, stock and customer records
  • Demand forecasting and replenishment usually pay off first, because the gain is visible in weekly stock and waste numbers
  • Recommendations need clean customer history; new customers and products need a fallback
  • Fresh food shows the trade-off clearly: over-ordering wastes stock, under-ordering loses sales
  • Models drift as habits change, so they need weekly checks and retraining
  • Start with one use case, a baseline and a short trial before widening the scope

Frequently asked questions

What data does retail machine learning need?

It needs complete sales, stock, price and promotion records, plus customer data where recommendations are involved. The records must be correctly labelled and cover enough history to show seasons and promotions. Missing or wrong records teach the model the wrong lesson, so a data check comes before any modelling.

Is machine learning only for large retailers?

No, but it helps most where there is enough repeated data to learn from. A small chain with a few stores and a full year of sales records can run a useful demand model. A single shop with patchy records will get more from fixing its stock counts than from buying a model.

How is machine learning different from a forecast in a spreadsheet?

A spreadsheet forecast usually applies one rule to all products, such as last week's sales plus a percentage. A model learns a different pattern for each product and store, and can include promotions, weather and local events. The difference shows in products whose demand moves in ways a single rule misses.

Can machine learning set prices automatically?

It can suggest prices, but most teams keep a human check and set limits on how far a price can move. Automatic changes on staple goods can damage trust, and a model can misread a one-off event as a lasting change. Test price changes on a small set of products first.

How do you know if a retail model is working?

Compare its predictions with what actually happened, on data it has not seen, and track the gap every week. The business measure matters more than the model score: waste, stock-outs, items per order or margin. If the business measure does not move, the model is not working.

What should a retailer do before buying a machine learning tool?

Fix the data first: check that sales, stock and price records are complete and correctly labelled, and pick one use case with a clear measure of success. A short trial on a small set of products will show whether the tool earns its keep before the team commits to a wider rollout.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning machine learning for a retail team? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Machine Learning Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call