A full-stack web application that fetches live stock data and runs 8 ML models to predict 7-day price forecasts with full evaluation metrics and visualizations.
| # | Model | Type | Library |
|---|---|---|---|
| 1 | Linear Regression | Baseline linear | scikit-learn |
| 2 | Ridge Regression | L2-regularized linear | scikit-learn |
| 3 | SVR (RBF kernel) | Support Vector Machine | scikit-learn |
| 4 | Random Forest | Ensemble (300 trees) | scikit-learn |
| 5 | Gradient Boosting | Boosted ensemble | scikit-learn |
| 6 | XGBoost | Extreme gradient boost | xgboost |
| 7 | LightGBM | Fast gradient boosting | lightgbm |
| 8 | LSTM (Sequence) | Sequence neural net | numpy |
XGBoost and LightGBM are the top performers for financial time series.
- Moving Averages: MA-5, MA-10, MA-20, MA-50
- EMA-12, EMA-26, MACD, MACD Signal, MACD Histogram
- RSI (14-period)
- ROC-5, ROC-10, Momentum-5
- Bollinger Bands: Upper, Lower, Width, %B
- Volatility (10-day rolling std)
- Price Change %, High-Low %, Close-Open %
- Volume MA, Volume Ratio
- Lag features: Close t-1, t-2, t-3, t-5
- MSE — Mean Squared Error
- RMSE — Root Mean Squared Error
- R² — Coefficient of Determination (fit quality)
- MAE — Mean Absolute Error
- 60-day historical price + all 8 model forecasts overlaid
- 7-day forecast bar chart (best model)
- Full prediction table (all models × 7 days)
- Model cards with full metric breakdown
- R² horizontal bar chart (all models)
- MSE & RMSE grouped bar chart
- Test accuracy % bar chart
- Python 3.9 or higher
- Internet connection (for live Yahoo Finance data)
cd Downloads
unzip stock_ml_predictor.zip
cd stock_ml_predictorpython -m venv venvWindows:
venv\Scripts\activateMac / Linux:
source venv/bin/activatepip install -r requirements.txtThis installs Flask, yfinance, scikit-learn, XGBoost, LightGBM, pandas, numpy.
python app.pyYou'll see output like:
🚀 Stock ML Predictor → http://localhost:5000
XGBoost : ✓
LightGBM : ✓
http://localhost:5000
- Enter any stock ticker (AAPL, TSLA, NVDA, AMZN, SPY, etc.)
- Click Analyze → or press Enter
- Wait ~20–40 seconds for training 8 models on 2 years of live data
- Explore all predictions, charts, and model evaluations
stock_ml_predictor/
├── app.py ← Flask backend + all 8 ML models
├── requirements.txt ← Python dependencies
├── README.md
├── templates/
│ └── index.html ← Main HTML page
└── static/
├── css/
│ └── style.css ← Dark theme UI
└── js/
└── main.js ← Charts (Chart.js) + frontend logic
Live OHLCV data from Yahoo Finance via yfinance — 2 years of daily data.
Final Project — Machine Learning & Data Science