ARIMA • SARIMA • STL + ARIMA Hybrid • NeuralProphet • Model Comparison
This repository contains a full end-to-end time-series forecasting workflow built on 5 years of daily data (2018–2022).
The dataset includes trend, yearly sinusoidal seasonality, and noise, allowing evaluation of classical and neural forecasting approaches.
The project is structured into modular notebooks covering ARIMA, SARIMA, STL decomposition, NeuralProphet, and a final model comparison.
This project answers one question:
Which model best forecasts a time series combining trend + yearly seasonality?
We explore four forecasting families:
- ARIMA — classical forecasting, handles trend but fails on strong seasonality
- SARIMA — seasonal ARIMA with weekly & yearly periods
- STL + ARIMA (Hybrid) — decomposes trend/season/residual, fits ARIMA on residuals
- NeuralProphet — neural forecasting model based on PyTorch Lightning
Finally, we compare all models using:
- MAE
- RMSE
- R²
- Forecast curves
- Residual diagnostics
- ADF test
- Differencing (d)
- ACF/PACF to choose (p,q)
- ARIMA(0,1,1) and ARIMA(1,1,1)
- Shows ARIMA fails to model the yearly seasonal cycle
- Flat predictions, residual seasonality, poor R²
- Attempts SARIMA with:
- m=365 (yearly seasonality) → too slow, unconstrained
- m=7 (weekly seasonality) → converges but wrong seasonal period
- Residuals still contain yearly sinusoidal shape
- SARIMA cannot capture large seasonal periods efficiently
- STL decomposes series into:
- Trend
- Seasonality
- Residual
- ARIMA is applied to residual component
- Final forecast reconstructed as:
trend + season + ARIMA(residual) - Achieved:
- MAE ≈ 0.40
- RMSE ≈ 0.51
- R² ≈ 97%
- Best classical forecasting method in this project
- Neural forecasting using PyTorch Lightning
- Automatically learns seasonal patterns
- Handles long seasonal cycles well
- Achieved:
- MAE ≈ 0.79
- RMSE ≈ 1.00
- R² ≈ 90%
- Loads all predictions
- Computes metrics (MAE, RMSE, R²)
- Plots all forecast curves on one chart
- Generates residual plots
- Produces a final comparison table
| Model | MAE | RMSE | R² | Notes |
|---|---|---|---|---|
| ARIMA | 2.86 | 3.33 | -7% | Failed seasonality |
| SARIMA | 3.19 | 13.03 | -0.26% | Wrong seasonal period |
| STL + ARIMA | ⭐ 0.40 | ⭐ 0.51 | ⭐ 97% | Best overall |
| NeuralProphet | 0.79 | 1.00 | 90% | Best neural model |
- Python
- Pandas, NumPy
- Statsmodels
- NeuralProphet
- PyTorch Lightning
- Matplotlib, Seaborn
- Scikit-learn
git clone https://github.com/<your-username>/complete-time-series-forecasting.git
cd complete-time-series-forecasting
pip install -r requirements.txt