Time series forecasting 2026: Prophet vs ARIMA vs Deep Learning
Forecast bán hàng, traffic, inventory — kỹ năng cốt lõi cho analyst/data scientist. Nhưng chọn model nào? Đây là so sánh thực tế, không phải marketing material.
4 option chính
1. ARIMA (cổ điển)
Autoregressive Integrated Moving Average. Mô hình thống kê truyền thống. Cần stationarity, tune (p, d, q) thủ công hoặc auto-arima.
Ưu: interpretable, ít data cũng chạy được (>30 điểm), fast Nhược: không handle seasonality tốt, không robust với outlier
2. Prophet (Facebook)
pip install prophet. Ra năm 2017, nhanh chóng thành default cho "quick forecast".
Ưu: handle trend + seasonality + holiday tự động, robust outlier, dễ dùng 5 dòng code Nhược: không tốt cho multi-variate (nhiều feature), accuracy khiêm tốn trên data phức tạp
3. LightGBM / XGBoost (gradient boosting)
Dùng time series features (lag, rolling mean, date features) → feed vào GBM.
Ưu: best accuracy thường thấy trong Kaggle, handle multi-variate, fast Nhược: feature engineering tốn công, dễ overfit nếu không careful
4. Deep Learning (LSTM, Transformer, N-BEATS)
Neural network tailored cho time series.
Ưu: học pattern phức tạp, handle multi-series (hundreds of products cùng lúc) Nhược: cần > 10k data points, training slow, hard to debug
Benchmark thực tế
M5 forecasting competition (2020, Walmart sales):
| Model | Weighted MAE | Training time | Data needed |
|---|---|---|---|
| Naive (last value) | 0.92 | 0s | minimal |
| ARIMA | 0.81 | 10 min | 100+ points |
| Prophet | 0.75 | 5 min | 100+ points |
| LightGBM | 0.58 | 30 min | 1000+ points |
| N-BEATS | 0.54 | 4h on GPU | 10k+ points |
Trade-off rõ: accuracy cao hơn = cost/time cao hơn.
Khi nào dùng cái gì
Use Prophet nếu:
- Single time series (1 store, 1 product)
- 2–5 năm history với daily/weekly data
- Cần báo cáo "trend + seasonality" dễ hiểu cho business
- Thời gian deliver: ngày
Use LightGBM nếu:
- Multi-series (nhiều product/store)
- Có nhiều feature: marketing spend, promotion, weather, holiday
- Accuracy là priority
- Thời gian: 1 tuần
Use ARIMA nếu:
- Univariate, stationary data
- Legacy system yêu cầu model simple
- Budget compute thấp
Use Deep Learning nếu:
100 related time series (global model)
- Dataset lớn (> 50k points tổng)
- Team có ML engineer + GPU
- Thời gian: 2–4 tuần
Code example: Prophet
import pandas as pd
from prophet import Prophet
df = pd.DataFrame({
'ds': pd.date_range('2023-01-01', periods=730),
'y': sales_data # daily sales
})
m = Prophet(
yearly_seasonality=True,
weekly_seasonality=True,
daily_seasonality=False,
changepoint_prior_scale=0.05 # less sensitive to outliers
)
m.add_country_holidays(country_name='VN')
m.fit(df)
future = m.make_future_dataframe(periods=90)
forecast = m.predict(future)
m.plot(forecast)
m.plot_components(forecast)
5 phút có 1 forecast đẹp + breakdown trend/seasonal/holiday.
Code example: LightGBM với time features
import pandas as pd
import lightgbm as lgb
def create_features(df):
df['dayofweek'] = df['date'].dt.dayofweek
df['month'] = df['date'].dt.month
df['lag_7'] = df['y'].shift(7)
df['lag_28'] = df['y'].shift(28)
df['rolling_mean_7'] = df['y'].shift(1).rolling(7).mean()
df['rolling_std_7'] = df['y'].shift(1).rolling(7).std()
return df.dropna()
df = create_features(df)
X = df.drop(['y', 'date'], axis=1)
y = df['y']
model = lgb.LGBMRegressor(n_estimators=500, learning_rate=0.05)
model.fit(X_train, y_train)
pred = model.predict(X_test)
Evaluation metric
- MAPE (Mean Absolute Percentage Error): dễ hiểu, nhưng buggy khi y gần 0
- SMAPE: fix cho y gần 0
- WMAPE: weighted theo scale (big store weight lớn)
- RMSE: penalize outlier mạnh
- Pinball loss: khi cần forecast quantile (P10, P50, P90)
Dùng MAPE + RMSE + visual plot. Không chỉ 1 metric.
Cross-validation cho time series
KHÔNG dùng random K-fold. Phải time-based split:
from sklearn.model_selection import TimeSeriesSplit
tscv = TimeSeriesSplit(n_splits=5, test_size=30)
for train_idx, test_idx in tscv.split(X):
X_train, X_test = X.iloc[train_idx], X.iloc[test_idx]
...
Mỗi fold train trên past, test trên future gần nhất.
Kết luận
Start với Prophet nếu time-to-deliver quan trọng. Upgrade LightGBM khi cần accuracy hoặc multi-variate. Deep Learning chỉ khi có budget + data.
Khoá Data Science & Analytics Level 4 có boss project: forecast 100 sản phẩm retail với LightGBM + WMAPE < 15%.