Think Build Implement Repeat
London, UK +44 7367 067226
WhatsApp FOLLOW f in X
AI & Machine Learning

Inventory Optimisation: Safety Stock Set by a Model, Not a Guess

Last updated:

Why the same rule for every product costs you twice

Walk into most distributors and ask how safety stock is set and you will hear something like two weeks of cover, or a minimum that someone set in 2019 and nobody has touched since. The rule is simple. It is also wrong in both directions at once.

Steady sellers with reliable suppliers carry far more buffer than they need, which is cash sitting on shelves. Erratic lines with a supplier who ships from overseas carry far too little, which is lost orders and angry phone calls. The average looks fine on a stock report. The individual products are not fine.

What safety stock actually depends on

Safety stock exists to absorb two kinds of uncertainty during the time between placing a purchase order and receiving it.

  • Demand uncertainty: how far actual sales stray from the forecast over the lead time
  • Supply uncertainty: how much the lead time itself varies, and how often deliveries arrive short
  • Target service level: the probability of not running out that you are willing to pay for

The textbook formula multiplies a service-level factor by the combined spread of those uncertainties. It is sound. The trouble in practice is the inputs: most businesses use sales history as the forecast and a supplier's quoted lead time as the lead time, and both are optimistic.

Where machine learning improves the numbers

A model does not replace the formula. It gives the formula honest inputs.

  1. Probabilistic demand forecasts. Instead of a single number, a forecast that says the 50th percentile is 120 units and the 95th is 190. Quantile regression or gradient-boosted models do this well and account for promotions, seasonality and price changes.
  2. Lead time prediction. Actual lead times learned from purchase order and goods-received dates, by supplier, by product group and by season. The quoted fourteen days often turns out to be nineteen, with a long tail around Chinese New Year.
  3. Intermittent demand handling. Slow movers that sell zero most weeks and six occasionally need different methods, and a model can pick the right approach per product.

If you want to see how the forecasting side is built, we have written about time-series forecasting for demand planning separately. This post is about what you do with the forecast once you have it.

A worked example with two products

Product A: cleaning concentrateProduct B: imported spare part
Average weekly sales400 units30 units
Forecast error (weekly)Low and stableHigh, lumpy orders
Quoted lead time5 days, UK supplier6 weeks, overseas
Actual lead time spread4 to 6 days5 to 11 weeks
Current rule2 weeks cover = 8002 weeks cover = 60
Model-based safety stock (illustrative, 97% service)Around 250Around 140

Notice that Product B's buffer barely depends on its average sales. It is driven by the five-week spread in when the container actually turns up. That is why a weeks-of-cover rule, which only looks at sales, gets imported lines so badly wrong.

The numbers are illustrative, but the direction is the usual finding. The steady local line is overstocked by several hundred units. The imported part is dangerously thin because the rule ignored the lead time variability entirely. Across a few thousand SKUs, that pattern is where the working capital goes.

Choosing service levels is a business decision

The model will happily calculate stock for a 99.5% service level on every product. That is expensive, because buffer rises steeply as you approach 100%. The useful conversation is which products deserve that.

  • High-margin lines and anything that loses the whole order if missing: high service level
  • Products with easy substitutes: moderate service level
  • Long-tail items where customers accept a lead time: low service level or make-to-order

We usually group products into three or four tiers and let the finance and sales leads agree the tier targets. That meeting is more valuable than any hyperparameter tuning.

When a spreadsheet formula is enough

If you stock a few hundred products, demand is fairly steady and suppliers are reliable, the classic formula with measured lead times in a spreadsheet will get you most of the benefit. Honestly, measuring actual lead times from your own purchase order history is the single most valuable step, and it needs no model at all.

Machine learning starts to pay when you have thousands of SKUs, promotions that distort demand, seasonal patterns, or suppliers whose lead times drift. It also helps when nobody has the hours to recalculate the formula for every product each month.

How we approach an inventory optimisation project

At SpiderHunts we begin with a stock health report built from your own history: which products ran out, which sat for months, and what the actual lead times were. That report alone often changes purchasing behaviour before any model exists.

Then we build the forecasts and lead time models, calculate recommended safety stock and reorder points per product, and push them back into the ERP or stock system as suggested values a buyer approves. After a quarter of approvals with few overrides, the suggestions can update automatically. This is standard data science work, and most of the effort is in data cleaning, particularly goods-received dates that were keyed in late.

Frequently asked questions

What is the formula for safety stock?

The common version multiplies a service-level factor by the combined standard deviation of demand over the lead time and lead time variability. The formula is fine; the value of a model is in producing realistic demand error and lead time inputs.

Can machine learning reduce inventory without more stockouts?

Often, yes, because it moves buffer from products that do not need it to products that do. Total stock may fall while availability on critical lines improves, though the result depends on how badly the old rules were set.

How often should safety stock be recalculated?

Monthly suits most businesses, with a check after big events such as a new supplier or a major promotion. Recalculating daily tends to create churn in purchase orders without much benefit.

Does this work with our ERP?

Usually. Most ERPs accept reorder points and minimums through an import or API. We recommend writing suggestions for a buyer to approve before letting any model change purchasing on its own.

What is a sensible service level to aim for?

There is no universal figure. Many businesses land somewhere between 90% and 98% depending on product tier, but the right number comes from comparing the cost of holding extra stock with the cost of a lost or delayed order for that product group.

Keep reading

Too much stock in some lines and stockouts in others?

Share a year of sales and purchase order history. We will show you which products carry the wrong buffer and what a model-based policy would change.

Book a free 30-minute call Get a project estimate WhatsApp us

Related services

What we build for problems like this one

AI AgentsMachine LearningAI Integration