Skip to content

Interview Questions — Sales Forecasting

These questions test whether a candidate understands the why behind the decisions in this project — not just the what. A practitioner should be able to explain the train-test split rule, the lag leakage trap, and the extrapolation ceiling without hesitation. The answers below model the level of depth and precision an interviewer expects.


Q1 — Why can't you randomly shuffle and split time series data for train and test?

Show answer

Randomly shuffling a time series before splitting destroys the fundamental structure of the problem.

In a time series, the past causes the future — or at least, the past is correlated with the future in a way that is the entire point of the forecasting exercise. When you shuffle rows, a training set row from December 2023 ends up next to a test set row from January 2021. The model trains on the future and is evaluated on the past. This is the definition of data leakage.

The consequence is that every metric — MAE, RMSE, R² — will be falsely optimistic. Lag features are especially dangerous: lag_7 at a shuffled test row will contain a value from a date that may come after the target in calendar time. The model learns to use future information and then appears to predict accurately, but it would fail entirely on real future data where those future values are unknown.

The rule is simple: train on the past, evaluate on the future. The cutoff date must be chosen before looking at any results. Everything before the cutoff is training data; everything after is test data. The split must respect chronological order.


Q2 — What is a lag feature and why is it useful for forecasting?

Show answer

A lag feature at time t is the value of the target variable at some earlier time t-k. For example, lag_7 at row t is the sales value from 7 days ago.

Lag features are useful because they give the model access to its own recent history. Instead of asking "what is the sales forecast for Monday November 6?", the model can ask "what were sales on Monday October 30?" — the same weekday, one week earlier. If sales on that previous Monday were high, there is a strong prior that this Monday will also be high.

In this project, lag_7 had a Pearson correlation of 0.91 with same-day sales — stronger than any calendar feature. This makes sense: weekly seasonality creates a near-perfect same-day-last-week signal. The model learns to anchor its prediction on lag_7 and then adjust up or down based on month, trend, and rolling averages.

Lag features are the most powerful feature type for time series because they encode the autocorrelation structure of the series directly. Classical time series models like ARIMA model this autocorrelation explicitly through autoregressive terms; lag features encode the same information in a form that any regression model can use.


Q3 — How do you avoid data leakage when creating rolling window features?

Show answer

The leakage risk is that a rolling window feature computed at time t might include the value at t itself — the very value you are trying to predict.

For example, if you compute rolling_mean_7 at November 10 as the mean of November 4–10, then the target value (sales on November 10) contributes to its own feature. This is circular and constitutes leakage: the model sees the answer embedded in its input during training.

The fix is to shift by 1 before rolling: compute the lag-1 series first, then apply the rolling window to that shifted series. This ensures the window at time t covers [t-window, t-1] — all past values, none of the current value.

In pandas:

shifted = df.groupby("category")["sales"].shift(1)
df["rolling_mean_7"] = shifted.groupby(df["category"]).transform(
    lambda x: x.rolling(7, min_periods=1).mean()
)

A practical way to verify: at time t, the rolling mean feature should equal the mean of the 7 values that appear in the lag_1 through lag_7 columns. If it is higher, you have likely included t in the window.


Q4 — What is MAPE and why might it be better than RMSE for a business audience?

Show answer

MAPE stands for Mean Absolute Percentage Error. The formula is:

MAPE = mean(|actual - predicted| / actual) × 100

It expresses the average forecast error as a percentage of the actual value.

MAPE is often better for business communication than RMSE for two reasons:

Scale independence. RMSE is in the same units as the target. An RMSE of 72 units means something different for a product that sells 1,000 units per day versus one that sells 100 units per day. MAPE normalises for scale: "5.7% average error" is immediately interpretable regardless of the category's volume. A sales manager can compare forecast accuracy across Electronics and Food without needing to know the absolute scale of each.

Interpretability. "Our model is off by 52 units on average" requires context to evaluate. "Our model is off by 5.7% on average" translates directly to business impact — inventory buffers, stockout risk, budget confidence intervals — without additional explanation.

The trade-offs: MAPE is undefined when actual values are zero (intermittent demand), and it is asymmetric — it penalises under-forecasting more than over-forecasting of the same absolute magnitude. For products with many zero-sales days, use weighted MAPE or MAE instead.


Q5 — Your gradient boosting model performs well on training data but makes poor predictions when future sales exceed the historical maximum — why?

Show answer

Tree-based models — including Gradient Boosting and Random Forest — predict by routing each input through a set of decision trees and averaging the leaf values of those trees. The leaf values are always within the range of the training targets.

This means a tree-based model cannot generate a prediction higher than the maximum target value it saw during training. If Electronics sales during training peaked at 1,573 units, the model is physically incapable of predicting 1,600 units, even when the trend, seasonality, and lag features all point strongly upward.

This is called the extrapolation problem: tree-based models interpolate within the training distribution but do not extrapolate beyond it. Linear models do not have this problem — a linear model with a time index feature will naturally project the trend forward.

The practical consequence: for a business growing 15–18% per year, a tree model trained on three years of data will become progressively under-conservative as the business grows. Multi-year forecasts will increasingly underestimate sales.

Mitigations include: detrending the series before modelling (fit on the residuals after removing the trend, then add the trend back to predictions), using a linear model for the trend component and a tree model for the residuals, or switching to a model that handles trends explicitly (LightGBM with a monotone constraint, or an ARIMA hybrid).


Q6 — How does TimeSeriesSplit work and why use it over standard KFold?

Show answer

Standard KFold splits the data into k folds by randomly partitioning the rows. In fold 3, the validation set might contain data from January 2021 while the training set contains data from December 2023. The model trains on the future and is evaluated on the past — the same leakage problem as random shuffling, applied to cross-validation.

TimeSeriesSplit creates folds that respect temporal order. With n_splits=5: - Fold 1: train on the first 1/6 of the data, validate on the next 1/6 - Fold 2: train on the first 2/6 of the data, validate on the next 1/6 - Fold 3: train on the first 3/6 of the data, validate on the next 1/6 - ...and so on

Each fold always trains on the past and validates on the immediate future. This mirrors real deployment conditions: you train on historical data and forecast the next period.

A secondary benefit: TimeSeriesSplit shows you how performance changes as the training window grows. If fold 1 RMSE is 92 and fold 5 RMSE is 76, the model improves with more data — useful information for deciding whether to collect more historical data.

Always use TimeSeriesSplit as the cv parameter in RandomizedSearchCV and cross_val_score when working with time series data.


Q7 — What real-world signals would you add if you had access to them?

Show answer

The most impactful additions, ranked by expected lift:

Promotion and discount flags. A binary is_promotional_day feature or a continuous discount_pct column would directly address the largest remaining error source. Promotional spikes look like noise to the current model but are entirely predictable if you have the promotion calendar in advance. This single feature could reduce Q4 MAPE by 30–50%.

Holiday calendar. A curated list of national and retail holidays (Thanksgiving, Black Friday, Cyber Monday, Christmas Eve, New Year's) encoded as binary flags or as days-until-next-holiday would help the model distinguish ordinary November days from peak shopping days.

Weather data. For Food and Home categories, temperature and precipitation correlate with purchasing behavior. Cold spells increase home heating product sales; rainy weekends increase online grocery orders. Weather data is freely available (NOAA, Open-Meteo) at the zip code level.

Inventory stock levels. If a product is out of stock, sales drop to zero even if demand is high. A model trained on sales data that includes stockout periods learns a false pattern. A days_of_inventory_remaining feature would let the model distinguish demand-driven drops from supply-constrained zeros.

Consumer confidence or macroeconomic indicators. The Conference Board Consumer Confidence Index, unemployment rate, or credit card spending indices correlate with discretionary category demand (Electronics, Clothing) over monthly horizons.

Competitor pricing signals. Web-scraped competitor prices (legal in most jurisdictions for publicly listed prices) are used by large retailers to adjust their own pricing and anticipate demand shifts.


Q8 — How would you turn this forecast into a business recommendation for the inventory team?

Show answer

A forecast number on its own is not a recommendation — it is an input. Converting it into a business recommendation requires connecting the model output to a specific decision with defined consequences.

For an inventory team, the decision is: how many units to order for the next week or month? The recommendation structure would be:

Lead time alignment. Determine the order lead time — if it takes 14 days to receive stock, the relevant forecast is the 14-day-ahead prediction, not the 1-day-ahead prediction. The model should be evaluated at the relevant horizon, not just the next day.

Safety stock calculation. The forecast gives the expected value, but the inventory team needs a buffer for uncertainty. Use the model's MAPE (~5.7%) to size a safety stock: if expected sales are 1,000 units, a 1.5× MAPE safety buffer adds ~85 units. For Q4, use the month-specific MAPE (~12%) to size the buffer appropriately larger.

Segment-specific communication. Electronics forecasts are more reliable (lower MAPE) than might be expected; Q4 forecasts are less reliable. Tell the team explicitly: "Trust the July–October forecasts within ±6%. Apply a ±12% buffer to November and December forecasts, and add a manual uplift for any planned promotions."

Concrete example format:

"For Electronics in the week of November 13–19, the model forecasts 8,400 total units. Based on a 12% Q4 uncertainty buffer, we recommend ordering 9,400 units. If a promotional event is planned during that week, add an additional 15–20% based on historical promotion lift."

This format is specific, quantified, and actionable — the inventory manager knows what to order and why.


← Evaluation