Skip to content

Rajesh-Arigala/complete-time-series-forecasting

Repository files navigation

📈 Complete Time-Series Forecasting Project

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.


🚀 Project Overview

This project answers one question:

Which model best forecasts a time series combining trend + yearly seasonality?

We explore four forecasting families:

  1. ARIMA — classical forecasting, handles trend but fails on strong seasonality
  2. SARIMA — seasonal ARIMA with weekly & yearly periods
  3. STL + ARIMA (Hybrid) — decomposes trend/season/residual, fits ARIMA on residuals
  4. NeuralProphet — neural forecasting model based on PyTorch Lightning

Finally, we compare all models using:

  • MAE
  • RMSE
  • Forecast curves
  • Residual diagnostics

📘 Notebook Summaries

🔹 01 — ARIMA Forecasting

  • 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²

🔹 02 — SARIMA Seasonality

  • 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

🔹 03 — STL + ARIMA Hybrid (Best Classical Model)

  • 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

🔹 04 — NeuralProphet Forecasting

  • Neural forecasting using PyTorch Lightning
  • Automatically learns seasonal patterns
  • Handles long seasonal cycles well
  • Achieved:
    • MAE ≈ 0.79
    • RMSE ≈ 1.00
    • R² ≈ 90%

🔹 05 — Model Comparison Engine

  • Loads all predictions
  • Computes metrics (MAE, RMSE, R²)
  • Plots all forecast curves on one chart
  • Generates residual plots
  • Produces a final comparison table

📊 Final Model Performance

Model MAE RMSE 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

🛠️ Technologies Used

  • Python
  • Pandas, NumPy
  • Statsmodels
  • NeuralProphet
  • PyTorch Lightning
  • Matplotlib, Seaborn
  • Scikit-learn

📥 How to Run the Project

git clone https://github.com/<your-username>/complete-time-series-forecasting.git
cd complete-time-series-forecasting
pip install -r requirements.txt