STOCK PRICE PREDICTION USING LSTM

What is the Stock Market?

The group of markets where investors purchase and sell stocks and other assets is known as the stock market. The public can purchase and sell shares of ownership in publicly traded corporations on the stock exchange. By purchasing a company's shares at a discount and reselling them at a premium, investors can profit. An important part of the global economy, the stock market gives companies money to grow and expand. It is also a well-liked method for people to make investments and gradually increase their money.

STOCK PRICE PREDICTION USING LSTM

A vital component of financial research is stock price prediction, This helps investors and traders make informed decisions about buying or selling stocks.This study proposes a model for predicting stock prices that predicts the closing price of Google stocks by using Recurrent Neural Networks  and Long Short-Term Memory. The Google stock dataset is used to train the suggested model at first. The Yahoo Finance API was used to gather historical stock data over a 20-year span. To give trend insights, important parameters including percentage changes, adjusted closing prices, and moving averages for 100 and 250 days were calculated. Sequences of 100 days were utilized as input to forecast the following day's stock price following the dataset had been preprocessed by standardizing the values using MinMaxScaler.
The LSTM-based model, including two LSTM layers succeeded by dense layers was assessed using 30% of the dataset after being trained on 70% of it. The model demonstrated strong performance with a Root Mean Square Error (RMSE) of roughly 4.31, signifying its precision in predicting stock prices. The predictions were then inversely transformed to match the original scale of stock prices for validation.To improve the prediction accuracy, we also employed a range of machine learning (ML) models, including Random Forest, Decision Tree, XGBoost, and Voting Classifier.
Furthermore, Streamlit was used to deploy the model in an intuitive interface that let users enter stock IDs and view projected prices in addition to moving averages. This study shows how well LSTM handles time-series data and how it may be used for real-time stock market forecasting and decision-making.

METHODOLOGY

The method for forecasting Google stock prices starts with obtaining 20 years' worth of historical data from Yahoo Finance using the `yfinance` library. For feature engineering, moving averages (100-day and 250-day) and daily percentage changes are computed after the dataset has been cleaned and examined for missing values and basic statistics. For the LSTM model, the data is organised into sequences and the Adjusted Close prices are normalised. RMSE is used to evaluate the model's performance after it has been trained on 70% of the data and evaluated on 30%. By contrasting projected and actual stock prices, predictions are visualised. Lastly, a Streamlit app for real-time stock predictions incorporates the trained model and saves it for later use.

RESULTS



CONCLUSION

This Stock Market Price Prediction project is designed to forecast stock prices based on historical data. The app’s user-friendly interface allows users to input a stock ticker (e.g., "GOOG") and select a date range, after which the app fetches relevant historical data from Yahoo Finance. A pre-trained LSTM model, known for capturing sequential dependencies in time-series data, is loaded to make predictions. The data is prepared by scaling and windowing, ensuring compatibility with the model’s requirements, and transformed back to the original scale for interpretable predictions. Additionally, the application features visualizations of moving averages over 100, 200, and 250 days, providing users with insights into both short & long term stock price trends. The app displays actual vs. predicted stock prices side by side, both in a table and on a line graph, giving users a clear view of the model’s performance. The LSTM model effectively captures overall price trends, though some deviations suggest areas for potential refinement. For a more comprehensive analysis, including error metrics like MAE & RMSE could help users better understand prediction accuracy. This project illustrates the power of combining machine learning with real-time data visualization to assist users in making informed investment decisions, with future potential to integrate additional models and real-time analysis capabilities to enhance accuracy and usability.Overall, this project highlights the capability of deep learning models to handle complex time-series data in the financial domain, making them powerful tools for real-time forecasting and analysis.




Comments