A hybrid AI-based stock market prediction system using LSTM, Random Forest, and XGBoost, built for real-world deployment with Optuna-powered tuning, feature-rich engineering, and ensemble prediction logic. Designed to optimize F1 score and accuracy, this system aims to generate reliable buy/sell signals on stocks. still work under progress
This project integrates:
- π Recurrent Neural Networks (LSTM) for sequential financial patterns
- π² Random Forest for ensemble-based classification
- β‘ XGBoost for gradient boosting decision trees
- π― Optuna for automatic hyperparameter tuning (optional mode)
- π Backtesting Module to simulate trading performance
βοΈ Built by a Computer Engineering student to demonstrate real-world ML/AI skills in finance and time series prediction.
- βοΈ Ensemble of 3 models: LSTM + RF + XGBoost
- βοΈ Flag-based retraining (no need to retrain every time)
- βοΈ Real stock data from Yahoo Finance
- βοΈ Feature-rich engineering: RSI, Moving Averages, Volatility, Volume
- βοΈ Backtesting for historical performance validation
- βοΈ Soft voting for final trade signal (BUY / SELL)
- βοΈ CLI-based output, no GUI bloat
- βοΈ Saved model reuse (
models/folder)
| Category | Stack |
|---|---|
| Language | Python 3.10 |
| ML Models | RandomForestClassifier, XGBClassifier |
| Deep Learning | TensorFlow / Keras LSTM |
| Optimization | Optuna |
| Data Source | yfinance |
| Indicators | RSI, MA5/10/20, Volatility, Volume |
LSTM-RandomForest-XGBoost-Stock-Predictor/ βββ LSTM+Random Forest+XGboost Stock Predictor.py βββ LSTM+Random Forest+XGboost Stock Predictor with optuna.py βββ backtest.py βββ models/ # Contains saved models βββ README.md βββ LICENSE # MIT License
pip install -r requirements.txt If no requirements.txt, install manually pip install yfinance numpy pandas scikit-learn xgboost tensorflow optuna
python "LSTM+Random Forest+XGboost Stock Predictor.py"
python "LSTM+Random Forest+XGboost Stock Predictor with optuna.py"
python backtest.py This will simulate trades and give statistics based on past 3 years of stock data.
π Processing RELIANCE...
β
Trained RF | Accuracy: 0.72 | F1: 0.75
β
Trained XGB | Accuracy: 0.74 | F1: 0.77
β
Trained LSTM | Accuracy: 0.76 | F1: 0.79
π RF Signal: BUY
π XGB Signal: BUY
π LSTM Signal: SELL
π’ Final Signal: BUY
β
Real-world applicability
β
Combines traditional ML and DL
β
Good F1/accuracy across multiple models
β
Shows model saving, loading, and production-like behavior
β
Demonstrates ability to tune, backtest, and validate system performance
This project is licensed under the MIT License.
Aarav Vinayak Mehta
B.Tech Integrated Computer Engineering
MPSTME, NMIMS Mumbai Campus
If you're a company looking for a student with real-world skills in AI, ML, and applied engineering β this is just the start. Let's connect on LinkedIn or drop me a message!