Unit 2 / 9

Demand Forecasting

Gains:

  • Ability to distinguish demand forecasting methods (moving average, exponential smoothing, seasonality)
  • Ability to set up prediction scenarios with AI and evaluate accuracy with metrics such as MAPE/MAE
  • Ability to cross-check forecast output with business context and promotional/seasonal effects

Demand forecasting is the basis on which production planning, inventory management and the entire supply chain are based. Wrong forecasting is expensive both ways: overestimating creates inventory costs and wastage, underestimating leads to lost sales and customer dissatisfaction. Artificial intelligence helps in many places in the forecasting process, from choosing a method to interpreting historical data and generating scenarios; But seeing the forecast as a "magic crystal ball" is the biggest mistake. In this unit, we will cover classical forecasting methods, how to build them correctly with AI, and how to measure accuracy.

Brief Map of Forecasting Methods

Not every series of demands behaves the same; Some are flat, some have trends, some are seasonal. It is necessary to choose the method according to the series.

Method

When is it appropriate?

Attention

Naive (last value)

For comparison (benchmark)

Does not follow the trend/season

moving average

Static, noisy series

Reacts late to the trend

Exponential smoothing (SES)

Stationary series, emphasis on nearby data

Good if there is no trend

Holt (double exponential)

Trendy series

Does not catch the season

Holt-Winters

Trend + seasonality

Requires sufficient historical data

Regression/ML

Multi-variable, promotion effective

Risk of overfit

Tip: Always start with a "naive" guess. If your complex model is no better than the naive guess, it's not worth carrying the complexity. Naive is a free benchmark for measuring accuracy.

How Do We Measure Accuracy? (Metrics)

Prediction accuracy cannot be improved without measuring it. The most common metrics:

  • MAE (Mean Absolute Error): The average of the absolute value of the errors. The unit is the same as the demand unit.
  • RMSE (Root Mean Square Error): Penalizes larger errors more.
  • MAPE (Mean Absolute Percent Error): In percent; Good for comparison between items, but distorted when demand is close to zero.
  • Bias: Average error; Indicates whether you consistently over/underestimate.

A small sample account. Let actual demand be [100, 120, 90], forecast be [110, 115, 100]:

Errors (actual - forecast): -10, +5, -10Absolute errors: 10, 5, 10 → MAE = 25 / 3 ≈ 8.33Percentage errors: 10/100, 5/120, 10/90 = 10%, 4.17%, 11.11%MAPE = (10 + 4.17 + 11.11) / 3 ≈ 8.43%Bias = (-10 + 5 - 10) / 3 = -5 → overestimation on average (prediction > actual)

A negative bias (true minus estimate) indicates that the estimate is consistently overestimated; This means inventory inflation. Such directional errors can be hidden in MAPE, so they are looked at together.

Building the Forecasting Process with AI

You can use AI most efficiently in two places: (1) to look at data and suggest the appropriate method and actions to be taken, and (2) to generate predictive code. For method suggestion:

Role: You are an industrial engineer experienced in demand forecasting. Task: Examine the monthly sales series below and recommend the appropriate forecasting method. Evaluate whether there is a trend and seasonality, write your justification. Data (monthly, last 24 months): {{ values ​​}}Additional information: There is a promotion in December, demand decreases in the summer months. The output I want:1. Comment on the character of the series (stable/trending/seasonal).2. 2 recommended methods and why.3. What accuracy metric should I track?4. Pitfalls I should watch out for (outlier, promotional effect).Rule: Don't promise absolute accuracy without seeing the data.

Weak Prompt / Strong Prompt

Weak prompt:

How much will I sell next month?

This contains neither data nor context; The AI ​​either rejects it or returns a completely made-up number. Such output is dangerous because it appears trustworthy.

Powerful prompt:

Predict the next 3 months using the Holt-Winters logic with this 24-month series. Season length is 12. First write the assumptions of the method, then give the forecast, then calculate the MAPE by backtesting the last 6 months. Mark the promotion months separately. Data: {{ ... }}

The second prompt asks for both the prediction and how much confidence to trust that prediction (backtesting). This transforms the prediction from an “oracle” into a measurable tool.

Backtesting: Measure of Confidence in Prediction

The real test of prediction is in the past, not the future. You divide the data you have into two: model building (train) and testing. You build the model with the first piece, predict the next period, and compare it with reality. This “hold-out” logic reveals whether a model is actually working or not.

Set up a simple backtest plan for the following series: set aside the last 6 months as testing, train 3 different methods (naive, SES, Holt-Winters) with the remaining data, calculate MAPE and bias for each during the testing period, and make a comparison table. Write the winning method and rationale.

Beware: AI can sometimes "predict" backtest results and present you with a ready-made chart; that is, he can make up numbers that seem reasonable without actually calculating them. Be sure to reproduce the numerical results with code (Python/Excel). A language model does not perform long arithmetic reliably.

Mini Case: Overstock of Seasonal Product

A food distribution company complains about having too much stock of a seasonal product like ice cream every year in the winter. Industrial engineer Elif gives 3 years of monthly data to the AI ​​and asks it to evaluate the character of the series. AI detects strong seasonality (summer peak) and a slight annual growth trend, Holt-Winters suggests. Elif generates the prediction in Python and backtests it: MAPE is 14%, but the bias is significantly negative — the model consistently overpredicts. When he investigates why, he finds that he mistook a campaign period in historical data as "normal" and taught the model too high a base. When we remove the campaign effect and rebuild the model, the bias decreases and the winter stock decreases significantly. Lesson: AI suggested the method correctly, but it was human work to clean the data and interpret bias.

Common Mistakes

  • Not tracking metrics: Estimating and never measuring accuracy. Prediction without measurement cannot be improved.
  • Just looking at MAPE: Ignoring bias. Directional (systematic) error silently inflates the inventory.
  • Mistaking the numbers made up by AI for calculations: Not validating backtest and metric values ​​with code.
  • Not cleaning the outlier/promotion: Mistaking a one-time campaign as a normal demand and teaching it to the model.
  • Overfit: When a complex model fits perfectly in the past but performs poorly in the future. Keep the simple model as a benchmark.

In summary

  • Choose the forecast method according to the character of the series (stationary, trending, seasonal); Always start by comparing yourself to a naive.
  • Measure accuracy with MAE/RMSE/MAPE, but also monitor bias: directional error is the most expensive.
  • Use AI for method recommendation and code generation; Set up the forecast as a measurable tool, not a "prophecy".
  • Backtesting is the real test of how much confidence a model can be; Be sure to verify numerical results with code.
  • It is the human's job to clean the data (outlier, promotion) and interpret the result; AI skips these steps.

Application task

Have at least an 18-24 period demand series (real or realistic fiction). First, give the AI ​​the series and ask it to interpret its character (trend/seasonality) and suggest two methods. Then use the "backtest plan" powerful prompt to reserve the last 6 periods as tests and compare at least two methods. Critical step: Recalculate the MAPE and bias values ​​returned by the AI ​​yourself with Excel or Python and compare them with the AI ​​output. If you find a number that doesn't match, write it down. Finally, interpret the sign of the bias: is your model overestimating or underestimating, and what does this do to your inventory?