This project implements a stock price prediction model using two different machine learning approaches: linear regression and Long-Short-Term Memory (LSTM) neural networks. The goal is to provide predictive insights into stock price movements using historical data from Yahoo Finance.
Research Paper - https://1drv.ms/b/c/87e0048ba6376a7d/EUPKbpK_j6dIgtuLYuGBNnQBpwREqJubv3_DSX9T34SmkQ Video Demonstration - https://youtu.be/z8sXhWrwU0o
- Automated stock data retrieval using
yfinance - Two prediction models:
- Linear Regression
- LSTM (Long Short-Term Memory) Neural Network
- Comprehensive data preprocessing
- Model training and evaluation
- Comparative analysis of prediction performance
- Python
- Tensorflow
- PyTorch
- yfinance
- pandas
- numpy
- Matlpotlib
- joblib
- sklearn
- Clone the repository:
git clone https://github.com/yourusername/Stock_Analysis_Prediction_Model.git
cd Stock_Analysis_Prediction_Model- Create a virtual environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows, use `venv\Scripts\activate`- Install required packages:
pip install -r requirements.txtStock_Analysis_Prediction_Model/
│
├── data/ # Raw and processed stock data
├── src/ # Source code for data fetching and model training
├── models/ # Saved trained models
├── tests/ # Unit tests for various components
├── images/ # Model performance visualization
├── requirements.txt # Project dependencies
└── main.py # Entry point for running the prediction model
To fetch historical stock data:
python src/fetch_data.pyTo train both Linear Regression and LSTM models & run predictions and compare model performance:
python src/main.pyThe project compares two machine learning models:
-
Linear Regression
- Simple, interpretable model
- Works well with linear relationships
- Faster training time
-
LSTM Neural Network
- Captures complex temporal dependencies
- Better at handling sequential data
- More complex architecture
The performance of each model is evaluated using:
- Mean Squared Error (MSE)
- Root Mean Squared Error (RMSE)
- Mean Absolute Error (MAE)
- R-squared (R²) Score
Detailed performance metrics are visualized in the pictures/ directory.
Run the test suite to verify model and data processing functionality:
python -m pytest tests/- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Stock predictions are inherently probabilistic
- Model performance depends on market conditions
- Past performance does not guarantee future results
Distributed under the MIT License. See LICENSE for more information.