InterviewBiz LogoInterviewBiz
← Back
Explain the Basics of Time Series Forecasting and Its Challenges
data-sciencemedium

Explain the Basics of Time Series Forecasting and Its Challenges

MediumCommonMajor: data scienceamazon, target

Concept

Time series forecasting is the process of predicting future values of a variable based on its historical behavior.
It plays a vital role in domains such as demand forecasting, finance, energy, and supply chain analytics.

Unlike traditional regression problems, time series data is temporally dependent — meaning past values directly influence future outcomes. This dependency introduces challenges like autocorrelation, non-stationarity, and seasonal effects that must be modeled explicitly.


1. Understanding Time Series Components

A typical time series can be decomposed into:

  1. Trend (T): Long-term directional movement — upward, downward, or stable.
    Example: Increasing e-commerce sales over years.

  2. Seasonality (S): Regular periodic fluctuations.
    Example: Higher retail sales every December.

  3. Cyclic Component (C): Non-fixed patterns tied to economic or natural cycles (e.g., market booms).

  4. Noise (ε): Random variation that cannot be explained by any pattern.

Formally:


Y(t) = T(t) + S(t) + C(t) + ε(t)

Understanding and separating these components helps build more interpretable and accurate models.


2. Classical Forecasting Models

A. ARIMA (AutoRegressive Integrated Moving Average)

  • Combines autoregression (AR), differencing (I), and moving average (MA) to handle temporal autocorrelation and non-stationarity.
  • Parameters: (p, d, q) where:
    • p = lag order,
    • d = degree of differencing,
    • q = size of moving average window.

Extended version SARIMA adds seasonal terms (P, D, Q, s).

Example: Forecasting monthly airline passengers with SARIMA(1,1,1)(1,1,1,12).


B. Exponential Smoothing (ETS)

  • Applies weighted averages where recent observations have more influence.
  • Variants include:
    • Simple Exponential Smoothing (SES) – for stationary data.
    • Holt’s Linear Trend – for trend data.
    • Holt-Winters – for trend + seasonality.

ETS models are interpretable and computationally efficient, making them ideal for business forecasting pipelines.


C. Prophet (Meta/Facebook)

  • Decomposes series into trend + seasonality + holiday effects using a Bayesian framework.
  • Handles missing data, outliers, and irregular intervals gracefully.
  • Highly favored for business use cases due to intuitive parameterization and explainability.

Example: Forecasting weekly demand while including known holiday promotions.


3. Modern and Machine Learning-Based Methods

A. LSTM (Long Short-Term Memory Networks)

  • Captures long-range dependencies and nonlinear relationships.
  • Ideal for sequential data like energy usage or stock prices.
  • Requires careful tuning (sequence length, dropout, optimizer).

B. Transformer-Based Forecasting

  • Models like Temporal Fusion Transformers (TFT) and Informer leverage attention mechanisms for long-horizon prediction.
  • Scales well across multiple correlated time series (e.g., multivariate forecasting).

C. Hybrid and Ensemble Models

  • Combine ARIMA for trend capture with ML (e.g., Random Forests, Gradient Boosting) for nonlinear residuals.
  • Often outperform single techniques, especially in complex systems.

4. Data Preparation Challenges

  1. Stationarity:

    • Most classical models assume constant mean and variance over time.
    • Apply transformations (differencing, log-scaling, Box–Cox) to stabilize.
  2. Seasonality and Trends:

    • Use decomposition or detrending before modeling.
    • Beware of seasonal leakage in validation.
  3. Missing or Irregular Timestamps:

    • Resample and interpolate carefully to maintain continuity.
  4. Feature Engineering:

    • Create lag variables (lag_1, lag_7), rolling statistics (e.g., 7-day average), or calendar features (day-of-week, holiday).

5. Evaluation Metrics

Use metrics appropriate for temporal forecasting:

| Metric | Formula | Interpretation | | --------- | -------------------- | ------------------------------------ | --- | -------------------------------- | --- | --- | --- | -------------------------- | | MAE | mean( | y - ŷ | ) | Average absolute deviation. | | RMSE | sqrt(mean((y - ŷ)²)) | Penalizes large errors more heavily. | | MAPE | mean( | (y - ŷ)/y | ) | Expresses error as a percentage. | | SMAPE | 2 × | y - ŷ | / ( | y | + | ŷ | ) | Symmetric version of MAPE. |

Important:
Avoid random cross-validation splits. Always split chronologically to simulate real-world forecasting.


6. Real-World Examples

1. Amazon Demand Forecasting

Amazon employs hierarchical time series models combining Prophet + XGBoost to forecast demand across products and regions, integrating weather and promotion effects.

2. Target Inventory Optimization

Target uses multivariate LSTM models to forecast product demand while factoring in regional trends and sales holidays, achieving measurable reductions in overstock.

3. Financial Time Series

ARIMA and GARCH models are used for volatility forecasting in finance, while neural approaches handle nonlinear dependencies.


7. Best Practices

  • Always visualize time series before modeling (trend plots, ACF/PACF).
  • Perform train-test split by time to prevent future data leakage.
  • Combine domain expertise (e.g., holidays, seasonality) with model diagnostics.
  • Ensemble multiple approaches for robustness.
  • Re-train regularly — model drift is inevitable.

Tips for Application

  • When to discuss:
    During interviews about forecasting, analytics, or ML in production systems.

  • Interview Tip:
    Mention both statistical and neural approaches:

    “We improved MAPE from 12% to 8% by combining SARIMA for seasonality with LSTM residual correction, while ensuring no temporal leakage through time-based CV.”


Key takeaway:
Time series forecasting requires balancing temporal structure, model complexity, and business context.
Success depends not just on the model choice but on robust preprocessing, leakage control, and interpretability of forecasts.