Method Selection
| Scenario | Best Method |
|---|---|
| Few series, clean data | Prophet, SARIMA |
| Many series (1000+) | LightGBM with lag features |
| Complex seasonality | N-BEATS, TFT |
| Real-time, low latency | Simple exponential smoothing |
LightGBM for Time Series
def make_features(df, lags=[1,7,14,28], windows=[7,14,28]):
for lag in lags:
df[f'lag_{lag}'] = df['target'].shift(lag)
for w in windows:
df[f'rolling_mean_{w}'] = df['target'].shift(1).rolling(w).mean()
df[f'rolling_std_{w}'] = df['target'].shift(1).rolling(w).std()
df['day_of_week'] = df.index.dayofweek
df['month'] = df.index.month
df['is_weekend'] = (df.index.dayofweek >= 5).astype(int)
return df
Backtesting Framework
Walk-forward validation: train on [0..t], predict [t+1..t+h], slide forward.