This project implements an Adaptive Hybrid Forecasting Model for stock price prediction by combining multiple statistical, machine learning, and deep learning models with advanced ensemble techniques.
The core idea:
Instead of relying on a single model, dynamically combine multiple models based on their recent performance.
- Statistical Models → ARIMA
- Machine Learning → Random Forest, Gradient Boosting
- Linear Models → Ridge, Lasso
- Deep Learning → LSTM
And combines them using:
- Adaptive Ensemble (dynamic weighting)
- Stacking (meta-learning)
- Combined Ensemble (Adaptive + Stacking)
- Data Collection (Yahoo Finance)
- Feature Engineering (technical indicators)
- Base Model Training
- Adaptive Ensemble (dynamic weights)
- Context-Aware Ensembles (Regime & Volatility)
- Stacking (Meta-Learner)
- Final Combined Model
- Evaluation & Forecasting
- Dataset Shape:
(1036, 21) - Source: Yahoo Finance (
yfinance) - Target Variable:
Close Price
| Category | Features |
|---|---|
| Returns | returns, log_returns |
| Moving Averages | MA(5,10,20,50,200) |
| Volatility | STD(5,10,20) |
| Trend | EMA(5,10) |
| Momentum | RSI, Momentum, ROC |
| Bands | Bollinger Bands (Upper, Lower, Width) |
| Context | Market Regime, Volatility Category |
| Model | Description |
|---|---|
| ARIMA | Classical time series model |
| Random Forest | Bagging-based ensemble |
| Gradient Boosting | Sequential boosting |
| Ridge | L2-regularized regression |
| Lasso | L1-regularized regression |
| LSTM | Deep learning sequence model |
- Uses rolling window performance
- Applies exponential decay weighting
- Prioritizes recent model accuracy
- Market Regime Adaptive (Bullish / Bearish / Sideways)
- Volatility Adaptive (Low / Medium / High)
- Meta-learner: Ridge Regression
- Validation: TimeSeriesSplit
- Combines predictions from base models
- Combined = 0.3 * Adaptive + 0.7 * Stacking
| Model | RMSE | MAE | MAPE | R² |
|---|---|---|---|---|
| ARIMA | 426.49 | 353.60 | 12.43 | -2.17 |
| RF | 78.47 | 35.32 | 1.33 | 0.89 |
| GB | 70.45 | 28.61 | 1.10 | 0.91 |
| Ridge | 11.43 | 8.38 | 0.28 | 0.997 |
| Lasso | 10.69 | 8.14 | 0.27 | 0.998 |
| LSTM | 90.58 | 59.65 | 2.14 | 0.85 |
| Adaptive | 20.21 | 13.57 | 0.48 | 0.99 |
| Adaptive (Regime) | 20.14 | 13.55 | 0.48 | 0.99 |
| Adaptive (Volatility) | 19.87 | 13.44 | 0.47 | 0.99 |
| Stacking | 26.75 | 15.44 | 0.57 | 0.98 |
| Combined | 23.76 | 14.62 | 0.53 | 0.98 |