Time Series Forecasting for Beginners: A Practical Guide

A practical introduction to time series forecasting — trend, seasonality and Indian festival effects, baselines, exponential smoothing and ARIMA, machine learning with lag features, proper backtesting and metrics, common mistakes, and a project to build — with tested Python code.

Quick Answer: Time series forecasting predicts future values from past observations ordered in time. Start by understanding trend, seasonality and special events — in India, festivals such as Diwali that move every year. Always build a simple baseline first, split data by time rather than randomly, evaluate with backtesting, and only then try exponential smoothing, ARIMA or machine learning with lag features. Good forecasting is mostly careful data handling and honest evaluation, not exotic models.

Forecasting is one of the most common data science tasks in Indian companies: how many units a store will sell next week, how much cash an ATM network needs before a long weekend, how many agents a call centre should schedule, how much electricity demand to expect during a heatwave. Yet it is often taught as an afterthought, and beginners carry over habits from ordinary machine learning that quietly produce misleading results.

This guide covers the concepts that matter, the main approaches, how to evaluate forecasts properly, and a tested Python example you can adapt.

What Makes Time Series Different

In most machine learning problems, rows are treated as independent. In a time series, order is everything: today's value depends on yesterday's, and the future is what you are trying to predict. That changes three things. You cannot shuffle data when splitting it. Features must only use information available at the time of the forecast. And patterns in time — trend, seasonality, holidays — become the main signals.

The Building Blocks of a Series

Trend is the long-term direction: steady growth in online orders, gradual decline in a legacy product. Seasonality is a pattern that repeats over a fixed period: higher sales on weekends, peaks at month-end when salaries arrive, summer spikes in air conditioner demand. Cycles are longer, irregular swings tied to economic conditions. Noise is the random variation left over. Plotting a series and decomposing it into these parts is always the first step.

The Indian calendar problem

Many Indian demand patterns are driven by festivals whose dates move each year — Diwali, Holi, Eid, Navratri, Onam, Pongal — along with regional holidays, wedding seasons, sale events and monsoon timing. A model that learns "late October is busy" will be wrong when Diwali falls in November. The fix is to build explicit features: days before and after each festival, a flag for sale periods, and regional holiday calendars. This single step often improves Indian retail forecasts more than changing the model.

Stationarity, Briefly

Classical statistical models such as ARIMA assume a series is stationary — its mean and variance do not drift over time. Real business series rarely are, so they are transformed: differencing removes trend, seasonal differencing removes repeating patterns, and taking logarithms stabilises growing variance. You do not need the theory in depth to start, but you should know why these transformations exist, because interviewers ask.

The Main Forecasting Approaches

ApproachHow it worksGood forWatch out for
Naive and seasonal naiveRepeat the last value, or the value from the same point last seasonBaselines every project must beatToo simple on their own, but often surprisingly hard to beat
Moving averageAverage of recent observationsSmoothing noisy seriesLags behind trends and turning points
Exponential smoothing (ETS, Holt-Winters)Weighted averages that adapt level, trend and seasonalitySingle series with clear patternsStruggles with many external drivers
ARIMA / SARIMAModels a series using its own past values and past errorsStationary or differenced single seriesNeeds care with parameters and seasonality
Machine learning with lag featuresTurns forecasting into regression with lags, rolling stats and calendar featuresMany related series, external drivers, holidaysLeakage if features use future information
Deep learningNeural networks trained across many seriesVery large collections of seriesRarely the best starting point; needs scale

In practice, teams often try a baseline, an exponential smoothing or ARIMA model, and a gradient boosting model with lag features, then compare them on the same backtest. Libraries such as statsmodels cover classical models, and scikit-learn, LightGBM or XGBoost handle the machine learning approach.

A Tested Python Example

The code below takes a daily sales series in a DataFrame with date and sales columns, splits it by time, builds a seasonal naive baseline, and creates lag features for a machine learning model:

df = df.sort_values("date").set_index("date")

# time-based split: never shuffle time series
train = df.loc[:"2026-03-31"]
test  = df.loc["2026-04-01":]

# seasonal naive baseline: same weekday last week
pred_naive = df["sales"].shift(7).loc[test.index]

# lag features for a machine learning model
feat = df.copy()
feat["lag_7"]  = feat["sales"].shift(7)
feat["lag_14"] = feat["sales"].shift(14)
feat["roll_28"] = feat["sales"].shift(1).rolling(28).mean()
feat["dow"] = feat.index.dayofweek

def mae(a, b):
    return (a - b).abs().mean()

print("Seasonal naive MAE:", round(mae(test["sales"], pred_naive), 1))

On a synthetic daily series with a weekly pattern, the seasonal naive baseline gave a mean absolute error of about 9.4, and a gradient boosting model trained on these features reduced it to about 7.5. Your numbers will differ; the point is the workflow — baseline first, then a model that must beat it.

Important: lags must be at least as long as your forecast horizon. A 7-day lag is fine for forecasting up to a week ahead, but if you need forecasts 30 days out, a 7-day lag would require values you will not yet have. Rolling statistics are shifted by one step for the same reason — so they never include the value being predicted.

Evaluating Forecasts Properly

Split by time. Train on the past and test on a later period. A random split lets the model see the future and produces scores that collapse in production.

Backtest across several periods. One test window can be lucky. Rolling-origin evaluation — train up to month one and test month two, then train up to month two and test month three, and so on — shows how stable performance really is. Make sure at least one test window covers your most important season, such as the festive quarter.

Choose metrics that fit the business:

MetricMeaningNote
MAEAverage absolute error, in the series' unitsEasy to explain: "off by 120 units a day on average"
RMSEPenalises large errors more heavilyUseful when big misses are costly
MAPEAverage percentage errorBreaks down when actual values are zero or near zero
WAPETotal absolute error divided by total actualsRobust for retail and demand data with many small values

Report uncertainty. A single number hides risk. Prediction intervals — "between 1,800 and 2,300 units with 80% confidence" — let planners decide how much buffer stock to hold or how many extra staff to schedule.

Forecasting Many Series

Real problems rarely involve one series. A retailer may need forecasts for thousands of product–store combinations. Building a separate model for each is slow and fragile, especially for products with little history. A common modern approach is a global model: one gradient boosting model trained across all series, with product, store and category features alongside lags. It learns shared patterns and handles new products better. Forecasts may then need to be reconciled so that store-level totals add up to regional and national totals.

A Step-by-Step Workflow

1. Define the decision. Who uses the forecast, at what level (SKU, store, region), for what horizon, and how often? A weekly replenishment forecast and an annual budget forecast are different problems.

2. Prepare the data. Fill missing dates explicitly, flag stock-outs and promotions, align time zones, and join calendar and holiday information.

3. Explore. Plot the series, decompose it, look at weekday and monthly patterns, and check how festivals and sales events show up.

4. Baseline. Build naive and seasonal naive forecasts and record their errors on your backtest.

5. Model. Try exponential smoothing or ARIMA, then a machine learning model with lags, rolling statistics and calendar features. Keep a simple log of each experiment.

6. Evaluate and choose. Compare on the same rolling backtest, including festive periods, and weigh accuracy against simplicity and maintenance.

7. Deploy and monitor. Schedule regular retraining, track error over time, and investigate when accuracy drops, which often signals a change in the business rather than a modelling problem.

Communicating Forecasts to the Business

Planners do not need model details; they need to know how much to order, stock or staff, and how confident to be. Present forecasts alongside last year's actuals and the baseline, show a range rather than a single line, highlight periods of high uncertainty such as festival weeks, and explain the main drivers in plain language. A forecast that people trust and use is worth more than a slightly more accurate one that sits in a notebook.

Common Beginner Mistakes

Shuffling data before splitting; creating features that use future values, such as a centred rolling average; ignoring holidays and festivals; using MAPE on data with zeros; tuning heavily on a single test period; forgetting that the business needs forecasts at a specific horizon and granularity; and presenting a point forecast with no sense of uncertainty. Another frequent one is not checking the data itself — stock-outs make sales look low when demand was actually high, and a forecast trained on them will under-predict.

Where Forecasting Is Used in India

Retail and e-commerce demand planning; quick-commerce inventory at dark stores; FMCG distribution; ATM cash and branch cash management in banking; electricity load forecasting for utilities; call-centre and delivery-partner staffing; airline and hotel demand; and payment volume planning for fintech platforms. In each, a better forecast translates directly into less wasted stock, fewer stock-outs or lower staffing cost — which makes forecasting projects easy to justify in rupees.

A Portfolio Project to Build

Take a public retail or electricity demand dataset, add an Indian holiday and festival calendar, and forecast four weeks ahead. Compare a seasonal naive baseline, exponential smoothing and a gradient boosting model with lag and calendar features, using rolling-origin backtests and WAPE. Show results separately for festive weeks, explain where each model fails, and finish with a recommendation and the estimated stock or cost impact. That one project demonstrates more than several generic notebooks.

Forecasting in Interviews

Typical questions include: Why can't you randomly split time series data? What is the difference between ARIMA and exponential smoothing? How would you handle Diwali in a forecast? Why might MAPE be misleading? How would you forecast for a brand-new product? How do you choose the forecast horizon and evaluation window? Answering with a concrete example — and mentioning a baseline unprompted — signals real experience.

Our Machine Learning course covers forecasting alongside other modelling techniques with real projects, and the Data Science course builds the Python, statistics and data-handling foundations first.

People Also Ask / FAQ

Which forecasting model should a beginner learn first?

Start with naive and seasonal naive baselines, then exponential smoothing, then gradient boosting with lag features. ARIMA is worth learning for interviews and single-series problems.

Is deep learning better for forecasting?

Not usually for beginners or modest datasets. Gradient boosting with good features and classical models often perform as well or better, with less effort.

How much history do I need?

Ideally at least two full seasonal cycles — two years for yearly seasonality — so the model can see each season more than once.

How do I forecast a new product with no history?

Use similar products' launch patterns, a global model with product attributes, or business judgement, and update quickly as real sales arrive.

Is time series asked in data science interviews?

Often, especially in retail, e-commerce, fintech and supply chain roles — usually about splitting, leakage, seasonality and metrics.

Learn Forecasting Through Real Projects

Live classes online and in select cities across India Explore the Machine Learning Course