Skip to content

hacess/stock-price-prediction-lstm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Stock Price Prediction using LSTM and Machine Learning

This repository contains code for predicting stock prices using Long Short-Term Memory (LSTM) neural networks. The model is trained on historical stock price data and predicts future stock prices based on past trends. The example here uses Apple's (AAPL) stock data from Yahoo Finance.

Table of Contents

Introduction

Stock price prediction has always been a key challenge in the financial industry. With the rise of machine learning, we can leverage models like LSTM (Long Short-Term Memory) to predict future stock prices based on historical data. LSTM is particularly suitable for time-series forecasting because of its ability to retain memory over long sequences.

Requirements

To run this project, you will need the following Python libraries:

  • numpy
  • pandas
  • yfinance
  • keras
  • matplotlib
  • scikit-learn

You can install them using pip:

pip install numpy pandas yfinance keras matplotlib scikit-learn

Usage

To train the model and make predictions, run the main.py file:

python main.py
``
The model will download historical stock data for Apple (AAPL) using the Yahoo Finance API and predict future stock prices based on past trends.

After training, the model will generate a plot of the actual vs predicted stock prices. An example output is shown below.

## Model Overview
This project uses an LSTM model to predict stock prices. The key components of the model include:

LSTM layers: For capturing the temporal dependencies in stock price data.
Dense layers: For transforming the outputs of the LSTM layers into predicted stock prices.
Optimizer: The Adam optimizer is used for minimizing the prediction error.

## Results
The model outputs a comparison of actual vs predicted stock prices. Below is an example plot generated by the model:
[<img src="https://www.codedbrainy.com/wp-content/uploads/2024/09/output-1.png">](https://www.codedbrainy.com/wp-content/uploads/2024/09/output-1.png)

## License
This project is licensed under the MIT License - see the LICENSE file for details.

About

Stock Price Prediction using LSTM and Machine Learning

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors