Skip to content

About

Predicting Yes Bank's monthly stock closing price using Ridge Regression, Random Forest & Gradient Boosting. Includes EDA, feature engineering & Streamlit app.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

📈 Yes Bank Stock Closing Price Prediction

Python Scikit-Learn License

📌 Project Overview

Yes Bank is a well-known bank in the Indian financial domain. Since 2018, it has been in the news because of the fraud case involving Rana Kapoor. This project analyzes how that event impacted the stock prices and builds ML models to predict the monthly closing price of Yes Bank stock.


🗂️ Folder Structure

YesBank_StockPrice_Prediction/
│
├── data/
│   └── data_YesBank_StockPrices.csv       # Raw dataset (OHLC monthly prices)
│
├── notebooks/
│   └── YesBank_StockPrice_Prediction.ipynb  # Main Jupyter notebook (EDA + ML)
│
├── models/
│   └── yes_bank_gbm_model.pkl             # Saved best model (pickle)
│
├── src/
│   ├── feature_engineering.py             # Feature engineering functions
│   ├── train.py                           # Model training script
│   └── predict.py                         # Prediction script
│
├── reports/
│   └── figures/                           # Saved EDA and model charts
│
├── streamlit_app/
│   └── app.py                             # Streamlit web app (optional deployment)
│
├── requirements.txt                       # Python dependencies
├── .gitignore                             # Files to ignore in git
└── README.md                              # Project documentation

📊 Dataset

Field Description
Date Month-Year of record
Open Opening price of the month
High Highest price in the month
Low Lowest price in the month
Close Closing price (TARGET)
  • Source: Yes Bank monthly stock prices (Jul 2005 – Nov 2020)
  • Total Records: 185 months

🔍 Project Architecture

  1. EDA → 15+ charts (Univariate, Bivariate, Multivariate)
  2. Data Cleaning → Missing values, outlier detection
  3. Feature Engineering → Lag features, moving averages, volatility metrics
  4. Preprocessing → MinMaxScaler, temporal train-test split (80/20)
  5. Model Building → Ridge Regression, Random Forest, Gradient Boosting
  6. Hyperparameter Tuning → GridSearchCV (5-fold CV)
  7. Model Explainability → Feature importance, residual analysis
  8. Deployment → Streamlit app (optional)

🏆 Best Model: Ridge Regression (Tuned)

Model Test RMSE Test R²
Ridge Regression - -
Ridge Regression (Tuned) Lowest ✅ Highest ✅
Random Forest (Tuned) Moderate Moderate
Gradient Boosting (Tuned) Moderate Moderate

Why Ridge won: The Open-Close relationship is nearly perfectly linear (r = 0.9995). When data is inherently linear, a well-tuned linear model outperforms complex ensembles — especially on a small dataset of ~185 records.


⚙️ How to Run

1. Clone the repository

git clone https://github.com/yourusername/YesBank_StockPrice_Prediction.git
cd YesBank_StockPrice_Prediction

2. Install dependencies

pip install -r requirements.txt

3. Run the notebook

jupyter notebook notebooks/YesBank_StockPrice_Prediction.ipynb

4. Run Streamlit app (optional)

streamlit run streamlit_app/app.py

📦 Libraries Used

  • pandas — Data manipulation
  • numpy — Numerical operations
  • matplotlib, seaborn — Visualization
  • scikit-learn — ML models, preprocessing, evaluation
  • pickle — Model persistence
  • streamlit — Web app deployment (optional)

💡 Key Insights

  • Yes Bank stock lost ~97% of its value between 2018–2020 due to the Rana Kapoor fraud
  • Open price is the strongest predictor of Close price (r = 0.9995)
  • Lag-1 autocorrelation = 0.97 — last month's price heavily predicts this month's price
  • March 2020 (RBI moratorium) was the most volatile month — >1400% intraday range
  • Simple linear model (Ridge) outperforms complex ensembles on this dataset — Occam's Razor in action

👤 Author

Your Name


📄 License

This project is licensed under the MIT License.

About

Predicting Yes Bank's monthly stock closing price using Ridge Regression, Random Forest & Gradient Boosting. Includes EDA, feature engineering & Streamlit app.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages