Case study — Shiftova

Forecasting restaurant sales: how I built it, then tested whether it's actually good

I built the sales forecast inside Shiftova, my scheduling app for restaurants. It learns from one restaurant's own sales history to predict how busy each day will be. This is how I built it, how I tested whether it's actually good, and what I learned, including what didn't work.

Short on time? Read the 1-minute version →

The short version, in plain English

  • A restaurant needs to know how busy each day will be, so it schedules the right number of people. Too few and service suffers. Too many and money is wasted.
  • I built a forecast that learns from the restaurant's own sales history, then tested it honestly: on real past days, using only what was known at the time.
  • It beats the franchisor's own method (the franchise's head office), mostly on holidays. Against simple averages the edge is small, and most of what's left is random day-to-day variation that nobody could predict.
  • The most useful discovery: sales jump the day before a mid-week public holiday and sag for two days after it. The forecast now accounts for that.

Throughout, “error” or “miss” means how far off the forecast was, as a percentage of what actually sold.

~41%

lower error on holidays than the franchisor's own formula

17.5%

typical miss on a single day, roughly the best this data allows: even a forecaster that secretly knew each weekday's true average would miss by 17.7%

26% → 22%

average miss on the days right next to a holiday, after the adjustment I found

0

forecasts changed on days that aren't next to a holiday (tested, not assumed)

At a glance

My role
Sole engineer and analyst: framing the problem, building the forecast, testing it, and launching it.
Data
About three years of daily sales (1,000+ days) from a live restaurant, anonymized here.
Methods
Forecasting that ignores freak days (robust regression), replaying history day by day to test it (backtesting), comparing against simple methods and against random variation, and checking whether a pattern is real or just luck (statistical testing).
Stack and status
Built in TypeScript with a PostgreSQL database (Supabase), automated tests, and no outside AI services. Live and in daily use at a real restaurant.

Skills used

Time-series forecastingBacktesting & validationStatistical testingRobust regressionExperiment designSQL / PostgreSQLTypeScriptData visualizationProduct analytics

The problem: a forecast that decides how many people work

A restaurant schedules its staff a week ahead. Forecast sales too high and it overstaffs and loses money. Forecast too low and service suffers. The obvious approach is to average the last few same-weekdays (the last few Tuesdays, say), which is also what the franchisor's own tool does. On a small restaurant's real data it breaks in three specific ways:

How it works: two parts working together

The data is daily sales entered by the restaurant: roughly three years, over 1,000 days. Real data has the problems you'd expect: typos, missing days, closures, one-off catering orders and holidays. The forecast has to cope with all of them without anyone cleaning the data by hand.

It has two parts. Part one learns the usual pattern from all the history: which weekdays are busy, how holidays behave, how the seasons change, and the long-run direction of the business. Part two looks only at the last 90 days and adjusts for how the business is running lately. Both parts use a method that automatically gives less weight to freak days (called robust regression), so one typo can't skew the result.

Two simpler designs failed first. In one, giving recent days extra weight distorted the seasonal picture and pointed it the wrong way months ahead. In the other, leaving out the long-run direction pushed that drift into the seasons instead, distorting them. Splitting the forecast into two independent parts fixed both.

  1. Daily sales history

    The most recent ~3 years of the restaurant's sales.

  2. Part 1: the usual pattern

    Weekdays, holidays, time of year and the long-run direction, learned from all the history. It also spots real repeating patterns on its own, but only if they showed up in 2+ years, clearly, the same way each time.

  3. Part 2: the recent adjustment

    How the last 90 days compare with the usual pattern. A hard cutoff, not a slow fade, so a real turnaround actually shows up.

  4. Forecast = usual pattern + recent adjustment

    Never below $0. A known one-off, like a big catering order, can be added by hand.

  5. Final forecast for that date

    Labelled low, medium or high confidence, based only on how much history exists. It reflects how much data there is, not a statistical margin of error.

What it spots on its own

The forecast can spot repeating patterns by itself, like a holiday that always sells unusually well or badly. But I made the bar deliberately high: a pattern has to show up in at least 2 years, be clearly unusual every single time, and always point the same way. One weak or contradictory year and it's rejected. That's on purpose, because once the forecast adopts a pattern it keeps applying it, so it needs strong evidence.

On the restaurant's multi-year history, it did find one recurring special day and one standout public holiday. It correctly refused to single out most other holidays, and found no reliable month-by-month pattern once the mix of weekdays was accounted for.

Before the fixAfterTrue value
$4,600 (holiday treated like any other)$2,026 (given its own adjustment)~$0 (the store is closed)

Roughly a 56% smaller miss for that one date. Every other holiday's forecast moved by under 2%, correctly unaffected, since none of them met the bar for their own adjustment. The fix is a fixed dollar amount, so it still under-corrects if that holiday ever lands on the busiest day of the week: a real improvement, not a complete fix.

How I tested it

A forecast is only as credible as its test. Every number below comes from a replay of history (called backtesting): for each day, the forecast sees only the sales from before that day, makes its prediction, and is then compared with what really sold. Nothing from the future can leak in. I ran it twice:

Results

Against the franchisor's formula

Average daily miss in dollars, once the forecast had 2+ years of history behind it

All days
$481
$453
Ordinary days
$467
$451
Holiday days
$895
$530
Franchise's formula Shiftova

The forecast wins by roughly 5.7% overall, and by roughly 41% on holidays. The honest picture: on an ordinary day, a 4-week average is already a reasonable guess, so the two land close together. The real advantage is where averaging simply can't work: the franchisor's formula has no way to know a date is a holiday or a special day. An average can't know a date is different. This can.

Against simple averages, and against random variation

Over the last year, on a typical day the forecast misses by about 14%. The average miss is about 17.5%, and roughly one day in ten is off by more than 38%. Weekly totals are off by about 7%. Whether that's good depends on what you compare it with:

Average miss on a single day, last 365 days

How far off the forecast was, as a percentage of what actually sold, with each day predicted using only earlier sales. *Hindsight floor: a forecaster that cheats by already knowing each weekday's true average for the year, a rough measure of the best this data allows.

Two things stand out, and I think both are worth saying plainly:

Where the misses are

I assumed the big misses would be large orders: days that sold far more than expected. They weren't.

The 28 days in the last year where the forecast was off by more than 40%
25 slumps3 spikes

Each square is one day. Slumps are days that sold far less than forecast; spikes sold far more.

That reframed the search. The question wasn't “how do I catch big orders?” (the app already lets a manager add a known one-off order by hand) but “what makes days slow?” So I listed the worst slumps. Many sat right next to a public holiday.

Key finding: the days around a holiday

I knew from experience that the day after a public holiday is usually slow. But “usually slow” isn't something you can build on, so I tested it against two years of data. It held up, and it was more specific than I expected.

How sales differ from the forecast, by number of days from a public holiday
+23%
−18%
−13%
−2%
−3%
−1%
+9%
−1%
+1%
Day before
+1
+2
+3
+4
+5
+6
+7
8–14comparison

How far actual sales were from the forecast, on average (positive = sold more than forecast), across about 20 holidays per column over two years. The last grey column is a comparison group: 130 ordinary days, 8 to 14 days after a holiday. The drops on days 1 and 2 are too large to be a coincidence (roughly 3.5 standard errors from zero, a standard yardstick for “could this be luck?”). The day-6 bump isn't.

The average hid the answer

My first attempt lumped every holiday together and barely helped. Then I split them by kind: a Monday long weekend versus a holiday that falls on any other day.

The same effect, split by the kind of holiday
+3%
+36%
−11%
−20%
−2%
−19%
Day beforen = 19 · 11
1 day aftern = 19 · 12
2 days aftern = 19 · 12
Monday long-weekend holidaysHolidays on any other day

Compared with the same weekday in the four weeks on either side. The n = shows how many holidays each bar is based on (Monday ones · other ones). Positive = sold more than a normal day.

A holiday in the middle of the week breaks the ordering rhythm. A Monday long weekend mostly doesn't. Lumped together, the average blended a big effect and a nonexistent one into a blur. Once split, the evidence for the day before was about twice as strong.

Building it so it can't hurt

I added it as a final adjustment that touches only those days, instead of building it into the main forecast, for three reasons:

It only switches on when the evidence is solid: at least eight past examples and a clearly real effect, and it deliberately under-corrects when it has few examples to learn from. With only a year or so of history it does nothing and waits. Each effect is measured against the same weekday in the four weeks on either side, which automatically accounts for the season and the direction the business was heading at the time.

Average miss before and after the adjustment, last 365 days

All days365 days

Before
17.5%
After
17.1%

Days next to a holiday33 days

Before
26.0%
After
21.7%

Replaying the last year using only past data. Of the 11 forecasts the adjustment changed, 9 moved closer to what actually sold. The adjustment is built into the forecast and ships with the next app release.

The overall gain is small because only about one day in eleven is affected. But those are the days where staffing goes wrong: too few people on the busy day before a mid-week holiday, too many on the slow days after. And the safety check held: zero forecasts changed on days that aren't next to a holiday, which I tested rather than assumed.

What didn't work

Negative results are part of the evidence. These are the ideas I tested that didn't pan out:

Lessons learned

  1. 1. Judge a forecast against simple alternatives and against pure randomness, not against perfection. A 17.5% miss sounds mediocre until you learn that even a forecaster that secretly knew each weekday's true average would miss by 17.7%.
  2. 2. Ask the person who knows the business, then test what they say. “The day after a holiday is usually slow” became the most useful finding of the project, but only after it was checked against two years of data and refined: it lasts two days, it isn't the holiday season, and it depends on the kind of holiday.
  3. 3. Averages can hide what's really going on. Lumping Monday long weekends in with mid-week holidays blurred a strong effect into a weak one. Split the data by a reason you can name before concluding an effect is small.
  4. 4. A pattern that looks real is only a hypothesis. The month-end bump looked convincing on the data I used to find it and vanished on data it hadn't seen. The holiday effect held up across years and across holidays, which is why it shipped and the other didn't.
  5. 5. Build a safety check you can prove. “Zero other forecasts changed” was verified by an automated test, not hoped for.
  6. 6. Check your own claims against what the code really does. The forecast labels each prediction low, medium or high confidence, and it's tempting to read that as a statistical margin of error. It isn't: it only reflects how many days of history exist. While writing this up, I found that the note in the code describing that label had drifted from what the code actually did, citing a threshold from a file that no longer exists, with a number that didn't match. The code was right; the note wasn't. I fixed it on the spot, and it's a habit I try to apply everywhere.

Limitations and next steps

Next: a comparison with ready-made forecasting tools, a public, reproducible version of the evaluation using made-up data, and more restaurants to test the holiday effect on.

Hiring, or building something similar?

I'm a full-stack developer with a computer science degree and over a decade of analytics-heavy product work, and I'm open to full-stack, backend and data roles as well as project work.