Stock prices are highly volatile and can be influenced by various factors such as news events, market sentiment, and economic data. The goal of this project is to predict Google stock prices using historical data and compare the performance of a simple Linear Regression model with a more advanced LSTM model.
Models Used:
- Linear Regression: A simple model that assumes a linear relationship between input (past stock prices) and output (future prices).
- LSTM (Long Short-Term Memory): A type of Recurrent Neural Network (RNN) that is capable of learning from sequential data, making it ideal for time-series prediction tasks like stock price forecasting.
The dataset for this project consists of historical Google stock prices, sourced from Yahoo Finance. The dataset includes:
-
Open, High, Low, and Close prices
-
Volume data For the purpose of prediction, I focused on the
closing prices, which are often considered the most accurate reflection of a stock's value at the end of the trading day. The data is preprocessed by normalizing the closing prices and splitting them into training and test sets.
You can view the deployed version of the stock prediction web app - https://prediction-goog-yf.streamlit.app/.
This application is hosted on Streamlit Cloud, which allows users to easily access and interact with the model's predictions. The app fetches stock data using the Yahoo Finance API and visualizes the predicted stock prices against actual prices.
To run this project locally, follow these steps:
- Clone the repository:
git clone https://github.com/udvale/stock-price-prediction.git
- Create a virtual environment (optional but recommended):
python -m venv myenv source myenv/bin/activate # On Windows use `myenv\Scripts\activate`
- Install required dependencies:
pip install -r requirements.txt
- Running Steamlit app:
streamlit run stock_prediction.py
- Open your web browser and navigate to the URL displayed in the terminal (usually http://localhost:8501).
- Input the desired stock symbol (default is "GOOG") and select a date range.
- Click "Load Data" to fetch and visualize the stock prices, and view the predictions.