Time-series interview questions on leakage, seasonality and backtests
In this article (17 sections)
- Concepts
- Q1. What makes a time series different from ordinary tabular data?
- Q2. Trend, seasonality and cycles — the difference?
- Q3. What is stationarity and why does it matter?
- Q4. What does an autocorrelation plot at lag 7 tell you for daily data?
- Leakage
- Q5. Name three ways leakage enters a forecasting pipeline.
- Q6. How do you build a 7-day rolling mean feature safely?
- Baselines and metrics
- Q7. What baseline would you beat before trying a model?
- Q8. Why is MAPE risky?
- Backtesting
- Q9. Describe a rolling-origin backtest.
- Q10. How long should the test window be, and how many origins?
- Scenario
- Q11. "Our forecast was fine all year and badly wrong in the Diwali week. What do you do?"
- How to practise
Related programme: the Data Science course (6 months; ₹1,30,000 (inclusive of GST) · EMI from ₹5,000/month).
Time-series interview questions mostly test one idea from several angles: a forecast may use only what was known at the moment it is made. Leakage through random splits, rolling features and future-dated joins is the most common failure interviewers probe, followed by seasonality, stationarity, choosing a baseline and designing a backtest. The eleven questions below are arranged from concept to hands-on, with a runnable rolling-origin backtest on hypothetical daily orders.
Concepts
Q1. What makes a time series different from ordinary tabular data?
Rows are ordered and usually dependent: today's value is related to yesterday's. That breaks the assumption behind random cross-validation and means the error of one forecast depends on how far ahead it looks.
Listening for: dependence and ordering, not only "it has a date column".
Q2. Trend, seasonality and cycles — the difference?
Trend is a long-run direction. Seasonality repeats at a fixed period — day of week, month, festival calendar. Cycles rise and fall without a fixed period, such as business cycles. A daily sales series in India might show weekly seasonality, an annual festival peak and a trend from store expansion.
Q3. What is stationarity and why does it matter?
A stationary series has a stable mean, variance and autocorrelation over time. Classical models such as ARIMA assume it after differencing. Machine learning models do not formally require it, but a strongly trending target makes tree models fail at new levels they never saw, which is why forecasting the change or ratio is often safer.
Q4. What does an autocorrelation plot at lag 7 tell you for daily data?
A high autocorrelation at lag 7 (and 14, 21) indicates weekly seasonality: each day resembles the same weekday a week earlier. It suggests a seasonal-naive baseline and day-of-week features.
Leakage
Q5. Name three ways leakage enters a forecasting pipeline.
- 1Random train-test splits, which train on the future.
- 2Rolling features computed with a centred window, or including the current day's value when forecasting that day.
- 3Joining an external table by date where the value was only published later — for example, a monthly figure released three weeks after month end.
Listening for: the third one. It is the hardest to spot and the one real pipelines get wrong.
Q6. How do you build a 7-day rolling mean feature safely?
Shift before rolling, so the feature for day t uses days t−7 to t−1:
import pandas as pd
s = pd.Series([10, 12, 11, 13, 30, 12, 14, 15],
index=pd.date_range("2026-03-01", periods=8, freq="D"))
safe = s.shift(1).rolling(3).mean() # window of 3 for a short example
leaky = s.rolling(3).mean() # includes the value being predicted
print(pd.DataFrame({"y": s, "safe_mean3": safe, "leaky_mean3": leaky}).round(2))On 5 March the leaky feature (18.0) already contains the spike of 30 it is supposed to predict; the safe feature (12.0) does not. If you forecast h days ahead, shift by h, not 1.
Baselines and metrics
Q7. What baseline would you beat before trying a model?
A naive forecast (tomorrow equals today) and a seasonal-naive forecast (tomorrow equals the same weekday last week). If a model cannot beat seasonal naive on a proper backtest, it is not ready.
Q8. Why is MAPE risky?
It divides by the actual value, so it explodes for small actuals and is undefined at zero, and it penalises over-forecasts and under-forecasts asymmetrically. For intermittent demand, use MAE, a scaled error such as MASE, or weighted MAPE computed as total absolute error divided by total actuals.
Backtesting
Q9. Describe a rolling-origin backtest.
Pick several forecast origins. At each, train only on data up to the origin, forecast the next h periods, and record the error. Move the origin forward and repeat. The average error across origins estimates real performance, and the spread shows how stable it is.
The block below backtests naive and seasonal-naive forecasts on four weeks of hypothetical orders with weekly seasonality:
import pandas as pd
weekly_pattern = [120, 100, 95, 98, 110, 160, 175] # Mon..Sun, hypothetical
orders = pd.Series(
[v + 2 * week for week in range(4) for v in weekly_pattern],
index=pd.date_range("2026-02-02", periods=28, freq="D"), # starts on a Monday
)
horizon, results = 7, []
for origin in [14, 21]: # train on the first 14, then 21 days
train, test = orders.iloc[:origin], orders.iloc[origin:origin + horizon]
naive = pd.Series(train.iloc[-1], index=test.index)
seasonal = pd.Series(train.iloc[-7:].values, index=test.index)
results.append({"origin": str(orders.index[origin].date()),
"naive_MAE": (test - naive).abs().mean(),
"seasonal_MAE": (test - seasonal).abs().mean()})
print(pd.DataFrame(results).round(1).to_string(index=False))Naive error is 51 orders at both origins, because the last training day is a Sunday, the busiest day, and its value is carried across the whole following week; seasonal naive misses only by the trend of 2 orders per week. That gap is what the interviewer wants you to explain.
Q10. How long should the test window be, and how many origins?
At least the forecast horizon, and enough origins to cover the seasonal cycle that matters — for retail with festival peaks, origins across more than one festival season if the history allows. One test window around a festival can make any model look good or bad by chance.
Scenario
Q11. "Our forecast was fine all year and badly wrong in the Diwali week. What do you do?"
Check whether the model knows about the festival: a fixed calendar-month feature misses a festival that moves between October and November, so add a holiday feature built from the actual dates. Compare the error in last year's festival week in the backtest; if it was also poor, the problem is structural. Consider separate handling for event periods — an uplift factor estimated from past festivals applied to the base forecast — and report event-week error separately so a good yearly average does not hide it.
How to practise
Take any daily series — orders from a practice dataset, or public weather records — and write the Q9 backtest with three forecast origins, then add one model and see whether it beats seasonal naive. Extending feature engineering with pandas to lag features is the natural next step, and error metrics are compared in the model evaluation bank. Forecasting with proper backtests is taught in the Data Science programme.
Frequently asked questions
Why can't I use random train-test split for time series?
A random split puts future observations in the training set and past ones in the test set, so the model learns from information it would not have when forecasting. The test score then overstates real forecasting accuracy. Use a split where every test period comes after all training data.
Pankit Kumar has 10 years in Data Science & AI, building and shipping production systems in regulated pharma and clinical environments. He is a freelance trainer at Boston Institute of Analytics, AnalytixLabs and Scaler, and has taught this material to thousands of working professionals.
This article is part of our Data Science programme — 6 months. From data foundations to machine learning, deep learning and deployment.
Explore Data Science