Skip to content
Blog

Forecast sales of a retail store using machine learning

Forecasting a week of retail sales

Inventory and staffing plans need a view of demand before the next trading week. This example uses seven days of recorded retail activity to forecast daily sales for the following seven days, then compares the forecasts with simple historical baselines.

942Source records
70Values in each input window
176Test forecast origins
0.781Day +1 test prediction R²

1. Business decision

The operational question is how much aggregate sales activity to expect over the next week. A useful comparison measures forecast errors in the same units and on the same dates as a simple reference forecast.

Seven-day history

Use the recorded calendar, sales, customer, opening and promotional fields from the previous week.

Seven-day forecast

Produce one sales estimate for each day of the following week.

Planning evidence

Compare errors with repeating the previous week; forecasting accuracy does not establish a promotion’s causal effect.

Demand planningRetail operationsForecast evaluation
This is an internal historical benchmark. The chronological windows do not cross subset boundaries, but the native preprocessing statistics use the saved used-row set, including later periods. A prospective evaluation must fit preprocessing within training and roll the forecast origin forward. Overlapping test windows are dependent. Results do not establish transfer to a different store, future period or promotional policy.

2. Data set

Seasonal patterns in the source series

The saved Neural Designer temporal means summarize all 942 daily records by calendar month, day of month and weekday. Each value is mean daily sales in the source units, not a monthly total. These descriptive averages cover the full source period; they are separate from the held-out forecast evaluation below.

Interactive chart: sales mean by month. Enable JavaScript to explore it.

Mean daily sales by calendar month. Native Neural Designer export.

Interactive chart: sales mean by day of month. Enable JavaScript to explore it.

Mean daily sales by day of month. Native Neural Designer export.

Interactive chart: sales mean by day of week. Enable JavaScript to explore it.

Mean daily sales by weekday. Native Neural Designer export.

Chronological evaluation

Source segmentFirst dateLast dateValid 14-day windows
Training01/01/201319/07/2014552
Validation20/07/201423/01/2015175
Testing24/01/201531/07/2015176

The prepared Rossmann table contains 942 daily records from 1 January 2013 to 31 July 2015. It is an aggregate retail series: there is one row per date, no store identifier, and the open and customers fields contain daily counts. The model therefore forecasts the supplied aggregate sales series, rather than a specific individual store. Sales retain the source file units; the prepared CSV does not label a currency.

The downloadable project, saved report and supplied source CSV define the exact version used here. Repository: original dataset/source record.

SubsetRecords
Training552
Validation / selection175
Testing176
Unused39
VariableRoleTypeEncodingUnit
dayInputNumericday of month
monthInputNumericmonth
yearInputNumericyear
day_of_weekInputNumeric1=Monday; 7=Sunday
openInputNumericdaily count
salesInputTargetNumericsource sales units
customersInputNumericdaily count
promoInputBinary0; 10 or 1
state_holidayInputBinary0; 10 or 1
school_holidayInputBinary0; 10 or 1

Interactive chart: sales distribution. Enable JavaScript to explore it.

sales distribution. Exported with Neural Designer from the saved task report.
Windows use chronological segments: 552 training origins, 175 validation origins and 176 testing origins. Thirteen starts per segment are excluded so their 14-day input-and-target windows cannot cross a boundary or the end of the series.

3. Model

The final model uses 10 features per day across 7 days (70 values) and produces 7 daily sales outputs. The following dimensions describe the final saved network.

LayerInput shapeOutput shapeActivation
Scaling7 107 10—
Recurrent7 109Tanh
Dense97Identity
Unscaling77—
Clamping77—

The final output is a continuous estimate. Scaling, unscaling and any bounds follow the saved implementation; the calculator does not silently impose physical constraints.

Forecasting a week of retail sales: initial Neural Designer architecture
Initial architecture before selection. The recurrent block processes the seven-day sequence; the output layer produces the next seven daily sales values.

4. Training strategy

Training uses normalized squared error, L2 regularization (weight 0.01) and the Quasi-Newton optimizer. Training minimizes the recorded objective; the validation subset monitors generalization during fitting. The testing subset is used for the evaluation below.

Interactive chart: Quasi-Newton method error history. Enable JavaScript to explore it.

Quasi-Newton method error history. Exported with Neural Designer from the saved task report.

Quasi-Newton method results

MeasureValue
Epochs number150
Elapsed time00:00:00
Stopping criterionMaximum validation error increases
Training error0.379
Validation error0.477

5. Model selection

The initial model has 5 recurrent neurons. The saved growing-neurons search evaluates 1–10 neurons with three trials and retains 9 neurons using validation error.

The following search results are recorded in the saved report. Selection used the validation subset. These are the selected settings within the tested search; they do not establish a globally optimal model.

Interactive chart: Growing neurons training/selection errors plot. Enable JavaScript to explore it.

Growing neurons training/selection errors plot. Exported with Neural Designer from the saved task report.

Growing neurons results

MeasureValue
Optimal neurons number9
Optimum training error0.2063
Optimum selection error0.3232
Epochs number10
Stopping criterionMaximum neurons reached
Elapsed time00:00:11
Forecasting a week of retail sales: selected Neural Designer architecture
Final architecture used for testing. The recurrent block processes the seven-day sequence; the output layer produces the next seven daily sales values.

6. Testing analysis

The final model is evaluated at 176 testing forecast origins, each producing seven future daily values. MAE, RMSE and prediction R² below are computed from the exact testing pairs stored by Neural Designer. Errors retain each target’s original units.

HorizonMAE (millions)RMSE (millions)Prediction R²Previous-week MAE (millions)
Day +10.7231.2740.7811.894
Day +20.7391.2890.7801.886
Day +30.7431.3140.7691.902
Day +40.7571.2960.7741.909
Day +50.7221.3120.7681.918
Day +60.7381.3100.7691.927
Day +70.7961.3690.7491.944

The native goodness-of-fit task reports squared Pearson correlation (r²). Prediction R² here is 1 − squared prediction error / squared deviation from the test mean. They measure different properties: a strongly correlated prediction can still have a bias or an incorrect scale.

Historical baselines

The weekly baseline repeats the seven input sales values as the next week. Persistence repeats the latest observed sales value for all seven horizons. All three use the same test origins and target dates. The table reports averages over the seven horizons, in millions of the CSV sales units.

ForecastMean MAE (millions)Mean RMSE (millions)
Recurrent model0.7451.309
Repeat the previous week1.9122.710
Repeat the latest observed day2.9153.886

The first and seventh horizons are shown below. The download includes native interactive charts for every intermediate horizon.

Interactive chart: sales (t+1) goodness-of-fit chart. Enable JavaScript to explore it.

sales (t+1) goodness-of-fit chart. Exported with Neural Designer from the saved task report.

Interactive chart: sales (t+7) goodness-of-fit chart. Enable JavaScript to explore it.

sales (t+7) goodness-of-fit chart. Exported with Neural Designer from the saved task report.

Interactive chart: sales (t+1) output plot. Enable JavaScript to explore it.

sales (t+1) output plot. Exported with Neural Designer from the saved task report.

Interactive chart: sales (t+7) output plot. Enable JavaScript to explore it.

sales (t+7) output plot. Exported with Neural Designer from the saved task report.

7. Model deployment

The JavaScript adapter keeps the generated arithmetic and exposes all seven computed outputs. The original HTML export exposed only the final horizon. The supplied inference.js is checked against every native test window; use it with the documented input order for batch forecasts.

Check seven days of inputs → apply the saved preprocessing and recurrent network → forecast the following seven days → review forecast errors and operating context. The ZIP contains the original project, source CSV, schema, test metrics and standalone interactive chart exports. The project hash in the schema identifies this exact version.

The model takes a 7 × 10 input window. For repeatable use, run the project in Neural Designer or call predict(inputs) from the downloadable inference.js. The input schema specifies the day-by-day order, from the oldest day to the latest; outputs are the next seven daily sales values.

8. Evidence and limitations

This is an internal historical benchmark. The chronological windows do not cross subset boundaries, but the native preprocessing statistics use the saved used-row set, including later periods. A prospective evaluation must fit preprocessing within training and roll the forecast origin forward. Overlapping test windows are dependent. Results do not establish transfer to a different store, future period or promotional policy.

No external validation or independent calibration study is included. Preprocessing statistics and model choices should be refitted within a prospective or grouped validation design. Correlations and directional responses describe associations, not causes. Human review is required before an operational decision.

References