How do you implement time series forecasting with modern ML methods?
Time series forecasting predicts future values based on historical patterns. Classical methods: ARIMA (captures linear trends and seasonality, good baseline), Exponential Smoothing (State Space models capturing level, trend, and seasonality), and Prophet (Facebook/Meta, handles holidays, trend changes, and missing data well). ML methods: gradient boosting (XGBoost, LightGBM) on engineered features (lags, rolling statistics, date features) provides strong performance with tabular approaches. Deep learning: Temporal Fusion Transformer (TFT) handles multiple time series with static and dynamic covariates, N-BEATS provides interpretable decomposition into trend and seasonality, and PatchTST applies transformer architecture to time series patches. Foundation models: TimesFM (Google), Chronos (Amazon), and Lag-Llama provide zero-shot forecasting without task-specific training. Feature engineering for ML: lag features (value at t-1, t-7, t-30), rolling statistics (mean, std, min, max over windows), date features (day of week, month, quarter, holiday flags), Fourier features for capturing cyclical patterns, and interaction features between covariates and temporal features. Evaluation: use time-based train/test splits (never random splits for time series), walk-forward validation (expanding or sliding window), and metrics appropriate for the use case: MAE (symmetric error), MAPE (percentage error, problematic near zero), RMSE (penalizes large errors), and MASE (scale-independent, compares to naive forecast). Multi-step forecasting: direct (separate model per horizon), recursive (use predictions as inputs for further predictions), or multi-output (single model predicts all horizons). Production: implement automated retraining (daily or weekly), monitor forecast accuracy degradation (concept drift), and implement ensemble methods combining multiple model types for robustness.