← All writing

Blog · MIS 382N Advanced DL/ML · UT Austin

Can Pretrained AI Forecast Walmart Demand?

November 2026

Pretrained AI models, used straight out of the box, forecast Walmart product demand 13% better than a simple 4-week average. The catch: they forecast only about 70% of the units that actually sell, so as-is they need $91,511 more safety stock than the baseline. Scaling their forecasts so totals match demand flips that to $27,305 less. Our own routing gate, which sends each product group to a different model, matched that fix but did not beat it.

Why we asked

In 2020, Kaggle's M5 competition asked teams to forecast daily Walmart sales 28 days ahead. The winners used LightGBM, a tree-based model, fed with carefully built features: past sales, rolling averages, prices, holidays.

Since then, "foundation models" for time series have arrived. Amazon's Chronos-2 and Google's TimesFM-3 are trained once on huge collections of time series, then forecast new data with no training at all. We wanted to know three things:

  1. Can these zero-shot models match models trained on Walmart's own data?
  2. Can post-processing (calibration, ensembles and a routing gate of our own) fix what they get wrong?
  3. What is the difference worth in safety-stock dollars?

That makes this a different question from M5's. M5 asked who forecasts most accurately. We asked whether a better forecast actually saves money on inventory.

M5 competition (2020)Our study
ScopeAll 10 stores in 3 states, 30,490 product-store seriesCalifornia's 4 stores, 12,196 product-store series
What it scoredAccuracy only: WRMSSE, a squared error across 12 levels of totals, weighted by dollar salesDaily error (MAE), volume (forecast ÷ actual units) and safety-stock dollars
What that rewardsForecasting the average, so slow sellers get a small positive forecastMAE alone rewards the median, which is zero for slow sellers. Volume and dollars catch that
ModelsWinners: LightGBM trained on the dataZero-shot foundation models vs. LightGBM vs. DeepAR

Our test month (Apr 25 to May 22, 2016) is M5's public leaderboard window, but our scores aren't comparable to the leaderboard.

The data: most products sell nothing on most days

We used the M5 dataset for Walmart's four California stores: 12,196 product-store series of daily unit sales from January 2011 to May 2016, plus weekly prices, holidays, events and SNAP (food assistance) days. We removed the days before each product first went on sale, since those zeros aren't real demand. That dropped 22% of rows.

The median product sells nothing on 60% of days. To see how models handle that, we split products into thirds by how fast they sold before our test periods:

Sales speedAvg units per dayDays with zero sales
Slow0.2382%
Medium0.6960%
Fast2.0932%

How we set it up

Every model forecasts 28 days ahead, the same horizon as M5, and only sees sales from before each window starts. Four backtest windows and two validation months are for learning and tuning; the test window (Apr 25 to May 22, 2016) is used only for final scores. We measure average error per product per day (MAE), a version weighted by dollar sales, and bias (whether forecasts run high or low), then turn forecasts into safety-stock dollars.

The models

ModelHow it worksTrained on our data?
Seasonal naive"Last week" repeats the same weekday last week; "4-week average" averages each weekday over the past 4 weeksNo training
LightGBMGradient-boosted trees with sales, price and holiday features, the M5 winners' approach; run with and without prices and holidaysYes
DeepARLSTM neural network reading 84 days of sales historyYes
Chronos-2 (Amazon)Pretrained transformer encoder; group attention lets it learn from related products. Run zero-shot, few-shot and fine-tunedNo (fine-tuned version: yes)
TimesFM-3 (Google)Pretrained decoder-only transformer that predicts the next chunk of sales, like next-word prediction; run zero-shotNo

We also ran both foundation models with prices and holidays as extra inputs. They gained only about 0.2%, and a review found that one price feature peeked slightly at future prices, so we report the clean zero-shot runs. LightGBM computes its price feature from past prices only, so both of its runs count.

Results: zero-shot AI wins, with no training

TimesFM-3 had the lowest error of any single model on the test window, 13% better than the 4-week average, without ever seeing Walmart data in training.

ModelMAE (units per product-day)Sales-weighted MAEvs 4-week averageBias (units/day)
TimesFM-31.0162.104+13%−0.41
Chronos-2, fine-tuned1.0212.127+13%−0.51
Chronos-21.0262.157+12%−0.47
DeepAR1.0842.368+8%−0.59
LightGBM + prices/holidays1.1042.261+6%−0.10
LightGBM, sales only1.1142.372+5%−0.12
4-week average1.1722.4190%−0.05
Last week1.3352.725−14%−0.07

Scored on the same 12,190 products for every model. Few-shot Chronos-2 came in at 1.036, slightly worse than zero-shot. Fine-tuned Chronos-2 had the best-calibrated forecast ranges of any model: its 80% range caught 79.8% of actual sales.

Bar chart of test-window error for every model, lowest for TimesFM-3 and highest for the last-week baseline
Test-window error for every model and post-processed version we scored. The Chronos-2 and TimesFM-3 "covariates" bars carry the price-feature leak and are left out of our headline.

Broken down by sales speed, the picture gets more interesting:

Improvement over 4-week averageFast sellersMedium sellersSlow sellers
TimesFM-3+11.5%+11.9%+25.1%
Chronos-2+10.4%+11.0%+25.2%
DeepAR+3.6%+9.4%+23.4%
LightGBM + prices/holidays+6.6%+5.8%+1.9%
TimesFM-3 + totals fix+9.1%+5.7%+1.7%

The biggest gains look like they come on slow sellers, but that's partly an illusion. The models' point forecast is the median, and when a product sells nothing on 82% of days, the median is zero. Forecasting zero scores well on MAE, yet it misses every day the product does sell. The two models that forecast real volume, LightGBM and TimesFM-3 with the totals fix, beat the baseline by only about 2% on slow sellers. Fast sellers are where the money is: their errors are about six times larger, and that's where DeepAR falls furthest behind.

Post-processing: fixing totals costs some daily accuracy

We tried three fixes on top of the raw forecasts. Each learns only from windows before the one it's applied to, so nothing is tuned on the test period.

FixWhat it doesTest MAEResult
EnsembleWeighted average of the models; weights chosen on earlier windows1.017Picked 0.6 TimesFM-3 / 0.4 Chronos-2 and gave DeepAR and LightGBM zero weight. No better than TimesFM-3 alone: the models make similar mistakes
calmaePer product group, picks the forecast percentile and zero cutoff with the lowest error1.014Almost no change: the median was already the best choice
calbias (totals fix)Per product group, scales forecasts so total units match actual sales1.086Total units forecast rose from 73% to 97% of actual sales, at about 7% more daily error

The totals fix is the interesting one. It trades a little day-to-day accuracy for forecasts that add up to the right volume, which is what an inventory planner actually needs. It scales the model's average forecast rather than its median, since zero times anything is still zero.

Our own idea: a routing gate

No single model is best at everything. The pretrained models have the lowest error on fast sellers but forecast zero for most slow sellers, while the totals fix and LightGBM plan for real volume. So we built a gate, a simple mixture of experts: instead of averaging models like the ensemble, it picks one. It splits products into 9 groups (3 categories × 3 sales speeds) and sends each group to one expert model.

The gate picks each expert on the two validation months only, never the test month. Picking by error alone would send slow sellers straight back to the models that forecast zero, so the gate uses error and volume together: among the models whose forecast lands within 90–110% of real units, it takes the one with the lowest error. Ten models competed, including raw TimesFM-3, raw Chronos-2 and both LightGBM runs. We built three versions, which differ in how many groups must pass the volume rule:

VersionGroups that must pass the volume ruleTest MAEForecast ÷ actual unitsSafety stock
Gate, slow onlySlow sellers1.0490.77$377,906
Gate, medium + slowMedium and slow1.0700.86$331,720
Gate, all groupsAll 91.0870.97$294,002
TimesFM-3 + totals fix(not a gate)1.0860.97$292,338

The gate is a dial, not a free win. The version with the lowest error leaves medium sellers at half their real units, and that costs about $86,000 more in safety stock. The version that passes the volume rule everywhere lands within $1,664 (0.6%) of the plain totals fix. The experts it picked tell the same story. With the volume rule on every group, it chose Chronos-2 with the totals fix in 6 groups and TimesFM-3 with the totals fix in the other 3. Raw TimesFM-3, raw Chronos-2, both LightGBM runs, DeepAR and the 4-week average never won a group. The ensemble was one of the ten candidates too: the slow-only version picked it for fast Foods and fast Hobbies, but it lost everywhere once the volume rule applied, because it forecasts too low. Scaling one strong model so its totals match demand already does what the gate was designed to do.

Why models behave differently

What a model aims for decides what it misses. Our error metric rewards the median, but inventory needs the average.

ModelWhat it aims forForecast ÷ actual unitsWhat it means
TimesFM-3, Chronos-2The median, which is zero for most slow sellers0.73 / 0.69Lowest error, and still best on fast sellers, but about 30% of demand goes unplanned
DeepARA range learned from 84 days of our sales0.61Forecasts the least volume of any model
LightGBMThe average (Tweedie loss, like the M5 winners)0.93Plans for real volume, at higher error on slow sellers
4-week averageThe average of the same weekday over 4 weeks0.97Nearly unbiased: the bar to beat
TimesFM-3 + totals fixIts average forecast, scaled so totals match demand0.97Cheapest safety stock: $292,338

A simple example: a product sells 1 unit every 4 days. The median day is 0, so a median forecast plans for nothing. The average is 0.25 a day, which adds up to the right total over a month even though it misses a little on every zero day.

What it means for inventory: low error isn't enough

Every AI model forecast too little. TimesFM-3's forecasts ran about 0.4 units per product per day low, while the simple 4-week average was almost unbiased. A store that orders from a forecast that runs low ends up with empty shelves.

To compare models fairly, each one's safety-stock buffer is sized so it covers 95% of weeks on the validation months, and only then do we compare dollars. Every model then covers about 86% of weeks in the test month:

ModelSafety stockvs 4-week average
TimesFM-3 + totals fix$292,338$27,305 less
Routing gate, all groups$294,002$25,640 less
Chronos-2 + totals fix$298,567$21,075 less
LightGBM + prices/holidays$316,585$3,058 less
4-week average$319,643(baseline)
TimesFM-3, as-is$411,154$91,511 more
Chronos-2, as-is$437,175$117,532 more
DeepAR$464,915$145,272 more

The most accurate model, used as-is, is one of the most expensive to stock, because the buffer has to make up the demand its forecast leaves out. With the totals fix it becomes the cheapest: 8.5% less safety stock than the baseline at the same service level.

What we learned

  • Zero-shot works. With no training on Walmart data, TimesFM-3 and Chronos-2 beat every simple baseline by 12 to 13% and beat both DeepAR and LightGBM, models trained on this data. Fine-tuning Chronos-2 helped by only 0.5%.
  • The metric picks the winner. Average absolute error rewards forecasting zero for slow sellers. M5 scored entries with a squared-error metric (WRMSSE), which rewards forecasting the average instead, and the winning LightGBM entries were built for that.
  • Inventory needs unbiased forecasts. The models with the lowest error forecast the least volume. A simple totals fix turns the most accurate model into the cheapest to stock: $27,305 (8.5%) less safety stock than the baseline.
  • Simple beat clever. Our routing gate tied the totals fix but did not beat it. One strong model, scaled so its totals match demand, already does the job.

Limitations: California only (4 of M5's 10 stores), one test window, and product-level scores rather than M5's official 12-level WRMSSE, so our numbers can't be compared to the Kaggle leaderboard.

What we'd try next: extend to all 10 stores and score with M5's official WRMSSE to see whether the ranking changes; forecast the average instead of the median for slow sellers; fix the price feature and re-run the foundation models with prices and holidays; and size safety stock with a real lead time and order cycle.

Team, code and tools

Group 8, MIS 382N Advanced Deep Learning and ML, UT Austin: Minji Kim (data prep, baselines, M5 research, routing gate), Elena Reyes (LightGBM), James Rainey (DeepAR), Prateek Bolandanda (TimesFM-3 full run), Max Volle (foundation models, scoring, post-processing).

Code: github.com/vollemax-lgtm/walmart-demand-forecasting. Pretrained models: Chronos-2 and TimesFM-3, used as released. Data: M5 Forecasting, Kaggle.

Sources: M5 Forecasting competition · In & Jung (2022), the 1st-place M5 method · M5 competition review