.png)
Summarize this article using AI
What Is Time Series Forecasting?
Time series forecasting is the practice of predicting future values of a variable from observations recorded at regular points in time. A time series is a sequence of such observations: monthly revenue, hourly electricity load, weekly orders. Forecasting differs from ordinary prediction because the order matters. Yesterday influences today, seasons repeat, and you must never use the future to predict the past.
The standard textbook, Forecasting: Principles and Practice by Rob Hyndman and George Athanasopoulos, notes that forecasting is required in many situations, for example that stocking an inventory may require forecasts of demand months in advance. That is the practical use: forecasts exist to support a decision.
What Do Business Time Series Look Like?
Business series usually mix several patterns:
- Trend: a long-run rise or fall, such as growing sales.
- Seasonality: a repeating pattern tied to the calendar, such as a December peak or a weekly cycle.
- Cycles and events: promotions, holidays, price changes, outages, lockdowns.
- Noise: random variation nobody can predict.
Before modelling, plot the series; a chart shows gaps, level shifts and outliers fast. Also decide the granularity (daily, weekly, monthly) and horizon (how far ahead). Daily data for a monthly decision adds noise without adding value.
Step 1: Start With the Decision, Horizon and Metric
Ask three questions before touching code:
- What decision will this forecast change? Ordering stock, staffing, cash planning.
- How far ahead, and how often? A weekly refresh for a 12-week horizon is a different problem from an hourly refresh for 24 hours.
- What does a miss cost? Over-forecasting leaves stock unsold; under-forecasting loses sales. If the costs differ, a symmetric error metric may mislead.
Write the answers down with the customer, as in the FDE project lifecycle.
Step 2: Prepare the Data
Real business data is messier than tutorial data. Check:
- Gaps and duplicates. Missing days, repeated rows, late-arriving records.
- Stockouts and censored demand. Sales are not demand if the shelf was empty.
- Outliers and one-off events. Decide whether to keep, cap or flag them.
- Calendar effects. Holidays, paydays, month-end, working days.
- Consistent units and currency. Merged systems often disagree.
- Level of aggregation. Product, store, region or total? A star schema helps keep time, product and location dimensions clear.
For the cleaning methods themselves, see data cleaning for AI projects, and for getting data to arrive reliably, AI data pipelines for messy enterprise data and Azure Data Factory.
Step 3: Beat the Baselines First
A baseline is a simple forecast any model must beat. Hyndman and Athanasopoulos write that some forecasting methods "are very simple and surprisingly effective," and list four to use as benchmarks:
- Mean: forecast the historical average.
- Naive: forecast the last observed value, which the book says "works remarkably well for many economic and financial time series."
- Seasonal naive: forecast the last value from the same season, such as the same month last year.
- Drift: extend the line between the first and last observations.
If a complex model cannot beat these, it is not adding value. We tested this on a synthetic monthly series: 72 months with a trend of 1.5 per month, yearly seasonality and random noise, using the first 60 months to train and the last 12 to test. The code used statsmodels 0.15.0:
python
from statsmodels.tsa.holtwinters import ExponentialSmoothing
f_mean = np.full(12, train.mean())
f_naive = np.full(12, train.iloc[-1])
f_snaive = train.iloc[-12:].values
hw = ExponentialSmoothing(train, trend="add", seasonal="add",
seasonal_periods=12).fit()
f_hw = hw.forecast(12).values
Two lessons. First, seasonal naive lost to plain naive here because it copies last year's level and ignores the trend; baselines must suit the data. Second, Holt-Winters won clearly, but this series was built with exactly a trend and a seasonal pattern, so it favours that model. Real data will not be this kind to any method. Treat the numbers as an illustration, not a benchmark.
Step 4: Choose a Model That Fits the Problem
There is no single best forecasting model. Common families:
Choose the simplest model that beats the baselines on a fair test and that the customer's team can maintain. For who does what on such a project, see forward deployed engineer vs data scientist.
Step 5: Evaluate Honestly With Time-Based Splits
This is the step where most forecasts quietly fail. The scikit-learn documentation states that ordinary cross-validation methods are inappropriate for time-ordered data because they would lead to training on future data and evaluating on past data. A university course based on the textbook says the same thing another way: "The test set must not be used for any aspect of model development or calculation of forecasts."
We tested the damage. Using the same synthetic series, we built a random forest with a time index, month, last month's value and the value 12 months earlier as features, and compared a chronological split with random splits:
python
# chronological: train on first 48 rows, test on last 12
rf.fit(X.iloc[:48], y.iloc[:48]); mae(y.iloc[48:], rf.predict(X.iloc[48:]))
# random: shuffle rows, hold out 20%
train_test_split(X, y, test_size=0.2, random_state=seed)
Evaluation
Mean absolute error
Chronological split (last 12 months held out)
15.0
Random split (average of 20 seeds)
3.73
The random split made the model look about four times better, because held-out months sat between training months and the model only had to interpolate. The real task, forecasting beyond the last month, needs extrapolation, which tree models do poorly for trends. The effect is model-dependent: with a simple linear model on lag features, the two gaps were small (3.86 chronological vs 3.61 random). The rule is not "random splits always inflate error." It is that you cannot know without testing the way the model will be used.
A single split is also fragile. Rolling-origin evaluation, also called time series cross-validation, moves the forecast origin forward and scores each step. The greybox documentation points out that with a single fixed origin, outliers or level shifts can let a poor model look better than a good one. In our test, four rolling folds with TimeSeriesSplit gave errors of 15.3, 6.43, 18.69 and 5.33, a threefold spread that one split would have hidden. Report the average and the range.
Choosing Forecast Accuracy Metrics
Metric
What it is
Caution
MAE
Average absolute error, in original units
Easy to explain; scale-dependent
RMSE
Square root of average squared error
Punishes large misses more
MAPE
Average percentage error
Breaks when actuals are zero; favours under-forecasting
MASE
Error scaled by a naive method's in-sample error
Compares across series; below 1 beats the naive
In our test, Holt-Winters scored a scaled error of 0.19 against 0.95 for seasonal naive, scaling by the training-set seasonal naive error. Pick the metric that matches the business cost, and show it next to the baseline's score so non-technical stakeholders can see the gain.
Step 6: Communicate Uncertainty
A point forecast is a single guess. A prediction interval shows the plausible range, and decisions often depend on the range: how much safety stock covers a bad week? Report intervals, check they are neither too wide to use nor too narrow to trust, and explain them in plain language ("we expect 1,000 to 1,400 units; planning for 1,400 covers most outcomes").
Step 7: Deploy, Monitor and Retrain
A forecast that is not refreshed decays. After launch:
- Track actual vs forecast automatically, by series and by horizon.
- Alert on drift: errors rising above the baseline, new product lines, pricing changes.
- Set a retraining rule, by schedule or by error threshold.
- Keep a human override and log why it was used.
- Version data, code and forecasts so results can be reproduced.
For streaming inputs, see Azure Stream Analytics; for who owns operations afterwards, read FDE vs MLOps engineer. Industrial settings add sensor data and downtime; see AI in manufacturing.
A Worked Scenario: Weekly Demand for a Retailer
This is a hypothetical example, not a case study.
A regional retailer wants a 12-week forecast of demand for 200 products to guide purchasing. The FDE starts by asking what the buyers will do with it, learns that orders are placed monthly, and sets a monthly decision cycle with a 12-week horizon.
Data checks find two problems: stockouts that depress recorded sales, and a promotion calendar kept in a spreadsheet. The FDE flags stockout weeks, joins the promotion data and aggregates to weekly level.
Baselines come first: naive and seasonal naive per product. A smoothing model and a gradient-boosted model with promotion features are then tested with rolling-origin evaluation across the last year. The boosted model wins on promoted items; the smoothing model wins on slow sellers. The team uses both, scored against the baseline per product group, with intervals for safety stock. A weekly job compares actuals with forecasts and flags products whose error exceeds the baseline's for four weeks.
The value came from framing, data fixes and fair testing, not a fancier algorithm.
Common Mistakes
- Random train/test splits. Always split by time.
- Skipping baselines. You cannot tell if a model helps.
- Using the future in features. Rolling averages and lags must use only past data.
- Judging on one test period. Use rolling origins.
- Treating sales as demand. Adjust for stockouts.
- Reporting MAPE on data with zeros. Use MAE or MASE instead.
- Ignoring intervals. Decisions need ranges.
- No monitoring plan. Accuracy decays quietly.
Practising for interviews? See Python skills for an FDE interview.
TL;DR:
Time series forecasting predicts future values from data recorded over time, such as daily sales or weekly demand. A reliable business workflow has six steps: tie the forecast to a decision, clean the data, beat simple baselines first, choose a model, test it on genuinely later data, and monitor it after launch. The most common failure is not a weak model. It is an unfair test, such as a random train/test split, that makes a forecast look better than it will be.
Frequently Asked Questions
What is time series forecasting in simple terms?
It is predicting future values, such as next month's sales, from past values recorded over time. It uses patterns like trend and seasonality while respecting the order of the data.
Which model is best for business forecasting?
No model is best everywhere. Start with simple baselines, then try exponential smoothing, ARIMA-type or feature-based machine learning models, and keep whichever beats the baselines on a time-based test and is maintainable.
Why can't I use a random train/test split for time series?
Random splits train on future data and test on past data, which does not match real use and can make results look better than they will be. In our test, a random forest's error looked about four times lower with a random split than with a chronological one.
What is a good baseline for forecasting?
Naive (last value), seasonal naive (same period last year), mean and drift are standard benchmarks. Pick the one that fits the data, and always show your model's gain over it.
How do I measure forecast accuracy?
Use MAE or RMSE in original units, MASE to compare against a naive method, and avoid MAPE when actual values can be zero. Evaluate on a time-based holdout or rolling origins.
How often should I retrain a forecasting model?
Use MAE or RMSE in original units, MASE to compare against a naive method, and avoid MAPE when actual values can be zero. Evaluate on a time-based holdout or rolling origins.
Become one of India’s first Forward-Deployed Engineers.
The world is hiring - and this Academy prepares you for it.
