How Bakeries Can Use AI to Predict Demand and Cut Unsold Stock

Coding Liquids tutorial cover featuring Sagnik Bhattacharya for How Bakeries Can Use AI to Predict Demand and Cut Unsold Stock.
Coding Liquids tutorial cover featuring Sagnik Bhattacharya for How Bakeries Can Use AI to Predict Demand and Cut Unsold Stock.

Bakeries use AI to cut unsold stock by forecasting each product for each weekday from their own till data, correcting for the days they sold out, adjusting for weather and events, then setting bake quantities by each item's margin. A spreadsheet plus ChatGPT or Claude, or a till with built-in AI, is enough to start.

What follows gives you a daily record sheet, a baseline forecast, a prompt for finding patterns, and a simple rule for how much of each product to bake. The main caveat: AI can only forecast from what you record. If you don't note when trays sell out, every tool, however clever, will tell you to bake too little of your best sellers.

Follow me on Instagram@sagnikteaches

Why your till underestimates what you could have sold

Your till counts sales, not demand. On a Saturday when the cinnamon buns sold out at 10.40am, the till shows 36 sold. The real demand might have been 55, but the customers who arrived at 11am and found an empty tray aren't in the data. Forecasters call this "censored demand", and it's the main reason bakery forecasts go wrong.

Connect on LinkedInSagnik Bhattacharya

The effect compounds. The forecast says "bake 36", you bake 36, you sell out early again, and the next forecast is lower still. Meanwhile the products that never sell out look accurate, so you keep overbaking the slow lines and underbaking the popular ones. Any AI tool you point at raw till data inherits this bias, which is why the first stage below isn't about AI at all.

Subscribe on YouTube@codingliquids

Stage 1: two weeks of better records (about five minutes a day)

Keep a sheet by the oven or on a tablet at the counter. One row per product per day:

ColumnExampleWhy it matters
Date and weekdaySat 12Weekday is the strongest pattern in most bakeries
ProductCinnamon bunForecast each line, not total sales
Baked36Lets you calculate leftovers and waste
Sold (from till)36Your recorded sales
Sold-out time10.40The fix for censored demand; blank if you didn't sell out
Left at close0Your waste, before any discounting
WeatherWarm, dryRain and heat shift what people buy
Event noteMarket dayKeeps one-off days from skewing the average

Most of this comes from the till's item report at close. The sold-out time and the event note are the only parts staff have to write down, and they're the parts that matter most. If you run on Square or Toast, the built-in assistant can pull the item counts for you: Square AI answers questions such as best sellers in a given hour, and Toast says Toast IQ, included with Toast POS, can answer questions about sales and menu performance.

Stage 2: a baseline you can build in an hour

Before asking AI anything clever, build a plain baseline: for each product and weekday, the average of the last six same weekdays, with sell-out days corrected.

The correction is simple. Look at a normal day when the product didn't sell out and work out what share of its sales had happened by each hour. Say that on typical Saturdays 60% of cinnamon bun sales have happened by 11am. On the day you sold 36 and ran out at 10.40, a fair estimate of demand is 36 ÷ 0.6 = 60. Round it down a little, to 55, to stay cautious. Your till's hourly sales report gives you these shares; so does asking the till assistant "what percentage of cinnamon bun sales happen before 11am on Saturdays?"

Put the corrected figures in a spreadsheet: products down the side, weekdays across the top, six weeks of history per cell. A weighted average that counts the most recent two weeks double will react faster to change without jumping at every blip. That table is your baseline, and on its own it often beats "same as last week" by a wide margin.

Stage 3: let AI find the patterns you can't see

Once you have six weeks of records, export the sheet as a CSV file and upload it to a chat assistant that can analyse files. ChatGPT and Claude both do this on their paid plans (about $20 a month). If your records live in Google Sheets on a Workspace Business Standard plan or above, Gemini works inside Sheets; if they're in Excel, Copilot does the same job on a Microsoft 365 Copilot licence. A prompt that works:

This file is my bakery's daily record: date, weekday, product, baked,
sold, sold-out time, left at close, weather, event note.
1. Where "sold-out time" is filled in, treat sales as a lower bound on demand.
   Estimate true demand using the share of sales normally made by that time
   on the same weekday for that product, and show your working for 3 examples.
2. For each product and weekday, give the average and the 75th percentile
   of estimated demand over the last 6 weeks. Exclude rows with an event note.
3. Tell me which products sell noticeably more or less on rainy days,
   and by roughly how much. Say if the data is too thin to tell.
4. List anything odd in the data (missing days, impossible numbers).
Output a table I can paste into a spreadsheet. Don't round silently.

Part of a typical first reply (sample output, illustrative):

Example 1: Cinnamon bun, Saturday 12th. Sold 36, sold out at 10.40. Across all days, 75% of cinnamon bun sales happen before 11am, so estimated demand = 36 ÷ 0.75 = 48. … Rain effect: sourdough sells about 18% less on rainy days. Pain au chocolat shows no clear rain effect.

Two things to fix, and the shown working is what lets you catch them. The assistant used the share across all days, not Saturdays, even though the prompt said same weekday; on Saturdays only 60% of bun sales happen by 11am, so the estimate should be 60, not 48. Point to the exact step ("use the Saturday share only") and ask it to redo all three examples. And the sourdough rain figure rests on three rainy days in six weeks. The prompt asked it to say when data is too thin; it didn't. Ask "how many rainy days is that based on?" before you change a single loaf.

Check the output before trusting it. Pick three products and recalculate one weekday by hand or in your spreadsheet. If the figures disagree, the assistant has misread a column or slipped on the arithmetic, which happens with long files; the reasons are covered in why AI is bad at maths and what to check. Ask it to redo the calculation using code and to show the formula it used.

What AI adds here is pattern-spotting you'd never have time for: that sourdough dips after rain but pain au chocolat doesn't; that the Wednesday after a public holiday behaves like a Monday; that savoury bakes jump on market days. For more ways to question a spreadsheet in plain English, see these Google Sheets AI prompts.

Stage 4: turn the forecast into a bake sheet using margin

A forecast tells you what demand probably looks like. It doesn't tell you how much to bake, because running out and having leftovers cost you different amounts for different products. The standard way to settle this, known in operations management as the newsvendor rule, fits in one line:

Aim to cover demand on this share of days: lost margin per missed sale ÷ (lost margin per missed sale + loss per leftover item).

Three illustrative products show why one rule for everything wastes money:

ProductPriceCost to makeLeftover recoversMissed sale losesLeftover losesCover demand on
Croissant$3.80$0.95Nothing$2.85$0.9575% of days
Sourdough loaf$7.00$2.40$2.00 as day-old$4.60$0.4092% of days
Cream slice$4.50$1.80Nothing$2.70$1.8060% of days

In practice: for croissants, bake to the 75th percentile of your corrected demand for that weekday. With eight Saturdays of history, sort them from lowest to highest and bake the sixth figure. In a spreadsheet, =PERCENTILE(B2:B9,0.75) does it. Say the eight corrected Saturday figures are 48, 52, 55, 57, 60, 61, 64 and 70: the sixth figure is 61, and the formula returns 61.75 because it interpolates between the sixth and seventh. Bake 62. The two methods rarely differ by more than a bun or two, so use whichever your team finds easier to check. Sourdough, which you can sell the next day, justifies baking generously. The cream slice, which you can't, should run lean and sell out some days, and that's the right answer, not a failure.

Two refinements matter. First, "cost to make" should include labour if the item is fiddly; a laminated pastry costs more than its flour and butter. Second, if customers who miss a cream slice happily buy a brownie instead, the true loss from a missed sale is smaller, so you can run leaner still. Ask the AI to spot this: "When cream slices sold out, did brownie sales rise afterwards on the same day?"

Suppose the answer suggests about half of the customers who miss a cream slice buy a brownie instead, and a brownie makes $2.20 of margin (illustrative figures). The real cost of a missed cream slice falls from $2.70 to about $1.60 ($2.70 minus half of $2.20). Put that into the rule: $1.60 ÷ ($1.60 + $1.80) is about 47%. So the cream slice should cover demand on fewer than half of days, and running out by early afternoon is the profitable outcome, as long as the brownies are there to catch the customers.

Stage 5: a plan for the last two hours of trading

Even a good forecast leaves some stock at close. Decide what happens to it in advance, so the decision isn't made at 5.45pm by whoever is tired:

  • A fixed markdown time. Discount at the same time daily, say 90 minutes before close, so regulars learn it and you don't train everyone to wait. Record markdown sales separately so they don't inflate next week's forecast. This slip is easy to make and slow to notice (illustrative): a bakery rang its 4pm half-price sourdough through the normal sourdough button. The forecast saw 12 extra loaves "sold" every Thursday and raised the Thursday bake, which left more to mark down, which raised the forecast again. Over six weeks the Thursday bake crept from 30 loaves to 41 while full-price sales stayed flat. A separate "end of day" till button fixed it, and the forecast settled back within three weeks.
  • Surplus-food apps. Apps such as Too Good To Go sell surplus as mixed bags for collection near closing time. They take a fee per bag and may charge a partner fee, which varies by market, so read the partner terms and count the fee in your "leftover recovers" column.
  • Day-old and repurposed lines. Bread pudding, croutons and breadcrumbs turn leftovers into a sellable product. Check food-safety rules for anything with dairy or fillings.
  • Donation. Useful for surplus that can't be sold, but count it as waste in your records, because it still cost you to make.

A worked month at a three-counter bakery

Say a bakery with a shop counter, a café counter and a Saturday market stall bakes 22 products. Before starting, the owner bakes roughly the same quantities every day and throws away or discounts about 14% of what's baked. Illustratively, on about $9,000 of weekly bake at retail value, that's roughly $1,260 of product not sold at full price.

Weeks 1-2: staff log sell-out times and events. Five minutes a day. The log shows cinnamon buns and sausage rolls sell out before 11am on most Saturdays, while seeded rye and lemon tarts come back almost every day.

Week 3: the owner builds the corrected baseline in a spreadsheet (about an hour) and runs the Stage 3 prompt through Claude. It flags that market-day Saturdays should be forecast separately and that rain cuts tart sales but lifts soup-and-roll sales at the café counter.

Week 4: the bake sheet switches to margin-based quantities. Rye and lemon tarts are cut by about a quarter; buns and sausage rolls rise by a tray each on Saturdays. The owner checks the sheet against the forecast each Friday; it takes 20 minutes.

To put a number on the month: if leftovers fall from 14% of what's baked to, say, 10%, then on the same $9,000 of weekly bake at retail value, product not sold at full price drops from about $1,260 to about $900 a week. Food cost is only part of that retail figure, so the saving to the business is smaller than $360, but the direction and size tell you whether the method is worth the 20 minutes each Friday.

The figure to watch is leftovers as a share of baked, product by product, alongside how often each product sells out before a set time. If leftovers fall and early sell-outs stay rare on your high-margin lines, it's working. If sell-outs climb, the cover percentages are too lean. Don't expect every week to improve; weather alone moves individual days a lot, so compare four-week blocks.

When the forecast goes wrong, and how you'll spot it

  • New products. There's no history. Borrow the pattern of a similar item for three weeks, bake cautiously and log sell-outs carefully. For a new pistachio bun launched beside the cinnamon buns, a sensible start is half the cinnamon bun's weekday pattern: about 25 on a Saturday against the buns' 55, 10 on a Tuesday. If it sells out before 11am on two Saturdays running, raise it by a tray; if more than a third comes back three times, halve it. After three weeks it has its own history and joins the normal forecast.
  • One-off days left unmarked. A street fair that doubles Saturday sales will push up the following Saturdays' forecast unless it's tagged as an event.
  • Wholesale mixed with counter sales. A café customer's standing order for 40 loaves isn't counter demand. Plan it separately and add it on top.
  • Changed hours or a new competitor. The past stops predicting the future. Shorten the history window to the last three weeks until things settle.
  • Weather beyond a few days. Only adjust for weather two or three days out; beyond that, forecasts aren't reliable enough to bake by.
  • Trusting the tool over the log. If the AI says bake fewer buns but staff logged sell-outs all month, the log wins. Recheck that sold-out times were included in the file.

For a longer list of how stock forecasts fail in small businesses, see why AI stock forecasts go wrong, and for the general mechanics beyond baking, AI inventory forecasting for small businesses.

Do you need specialist bakery software?

There are bakery production and forecasting systems that connect to your till, pull in weather and events, and produce a bake sheet automatically. They make sense when you run several sites, bake dozens of lines, or need wholesale orders and counter demand in one plan. Vendors in this space often quote large waste reductions; treat those as marketing until you've seen it on your own data.

A fair test: give the vendor your last two months of records, ask it to forecast the following four weeks without seeing them, and compare its numbers with your spreadsheet baseline. If it doesn't clearly beat the baseline, the spreadsheet and a $20 assistant are doing the job already. Square users can also check their dashboard for Managerbot, which Square opened to more sellers in open beta in April 2026 at no extra cost and which it says flags likely shortages by tracking sales against stock.

Bakery forecasting questions

How much sales history do I need before AI forecasting is useful?

Six to eight weeks of daily sales by product gives a usable weekday pattern. A full year helps with seasonal swings such as summer holidays or the run-up to Christmas, but you don't need to wait for it. Start with what you have, and mark unusual days as events so they don't distort the averages while the history builds up.

Should I buy specialist bakery forecasting software?

Consider it once you run several sites, bake more than about 40 products daily, or supply wholesale customers whose orders need to feed the plan. Below that, a spreadsheet plus a chat assistant usually does the job. If you trial a specialist tool, ask it to forecast last month blind and compare its figures with what actually happened before you commit.

Can AI tell me the weather effect on my sales?

It can estimate it if you give it the data. Add a daily column with the maximum temperature and whether it rained, then ask the assistant to compare sales on similar weekdays with and without rain. Treat the result as a rough adjustment, and only use forecasts for the next two or three days, since longer-range weather forecasts are much less reliable.

Is it safe to sell or give away leftover bakes the next day?

That depends on the product and on food-safety rules where you trade. Bread and many dry bakes are commonly sold as day-old at a discount; cream, custard and filled items usually aren't. Check with your food-safety inspector or local environmental health service, and write your rules into your end-of-day plan so staff don't have to guess.

Further reads

Sources: Square press releases on Square AI and Managerbot (April 2026); Toast IQ product page; Microsoft 365 and Google Workspace pricing pages; OpenAI and Anthropic plan pages, checked September 2026. The margin-based bake rule is the standard newsvendor method from operations management, explained here in plain terms.

Want a bake plan that follows your real sales?

On a 1:1 call we'll look at what your till already records, set up the sell-out log and baseline, and build a bake sheet your team can update each week without me.

Book a 1:1 call with me