Skip to content

Quantamaster/stock-Market-Price-Prediction-using-ML

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


📈 Stock Price Prediction with LSTM (Streamlit App)

Python Streamlit TensorFlow Keras License Status

A Streamlit-based web application that predicts stock prices using a Long Short-Term Memory (LSTM) neural network. Users can upload historical stock price data, tune model hyperparameters interactively, train the model, and visualize actual vs predicted prices along with performance metrics.


📑 Table of Contents


🔍 Overview

This application demonstrates how LSTM-based deep learning models can be applied to time-series forecasting in finance. It allows end users to:

  • Upload custom stock datasets
  • Experiment with different hyperparameters
  • Train an LSTM model in real time
  • Visualize predictions and training performance

🏗 Architecture

Architecture


🔄 Pipeline

Pipeline


✨ Features

  • 📂 CSV Upload – Upload historical stock price datasets

  • 👀 Data Preview – Inspect uploaded data before training

  • 🎛 Dynamic Hyperparameter Tuning

    • Sequence length (look-back window)
    • Epochs
    • Batch size
    • LSTM units (Layer 1 & 2)
    • Train–test split ratio
  • 🚀 One-click Model Training

  • 📉 Training Loss Visualization

  • 📊 Performance Metrics – Mean Squared Error (MSE)

  • 📈 Interactive Prediction Plot – Actual vs Predicted prices


🛠 Tech Stack

  • Frontend: Streamlit
  • Backend / ML: TensorFlow, Keras (LSTM)
  • Data Processing: NumPy, Pandas
  • Visualization: Matplotlib
  • Preprocessing: Scikit-learn (MinMaxScaler)

📦 Requirements

  • Python 3.8+

  • Libraries:

    streamlit
    numpy
    pandas
    matplotlib
    scikit-learn
    tensorflow

⚙️ Installation

pip install streamlit numpy pandas matplotlib scikit-learn tensorflow

▶️ How to Run

  1. Save the Application

    app.py
  2. Prepare CSV Data Your dataset must contain a Close column.

    Example format:

    Date,Open,High,Low,Close,Volume
    2023-01-01,100.0,102.5,99.5,101.0,100000
    2023-01-02,101.5,103.0,100.0,102.0,120000
  3. Run the App

    streamlit run app.py
  4. Access the Application

    http://localhost:8501
    

🧭 Usage Guide

  1. Upload CSV via the file uploader

  2. Verify Data Preview (ensure Close column exists)

  3. Configure Hyperparameters using sidebar sliders:

    • Look-back window
    • Epochs
    • Batch size
    • LSTM units
    • Train–test split
  4. Train Model using the Train Model button

  5. Analyze Results:

    • Training loss curve
    • Mean Squared Error (MSE)
    • Actual vs Predicted stock price graph

🧠 Model Architecture

The model is built using Keras Sequential API:

  • MinMaxScaler Normalizes prices between 0 and 1

  • Sequence Generator (create_sequences) Converts time series data into LSTM-ready sequences

  • LSTM Layer 1

    LSTM(units=lstm_units_1, return_sequences=True)
  • LSTM Layer 2

    LSTM(units=lstm_units_2)
  • Dense Output Layer

    Dense(1)
  • Optimizer: Adam

  • Loss Function: Mean Squared Error


📊 Evaluation Metrics

  • Mean Squared Error (MSE) Measures average squared difference between actual and predicted prices

⚠️ Important Notes

  • 🚨 For educational purposes only

  • 📉 Stock market prediction is highly volatile and uncertain

  • 📊 Model performance depends heavily on:

    • Data quality
    • Data size
    • Hyperparameter choices
  • ❌ Not intended for financial or investment advice


🚀 Future Enhancements

  • Add technical indicators (RSI, MACD, EMA)
  • Support multi-stock prediction
  • Integrate real-time data via APIs
  • Deploy as a cloud-based API (GCP / AWS)
  • Add model comparison (LSTM vs GRU vs Transformer)

📄 License

This project is licensed under the MIT License.


About

Web application that allows users to predict stock prices using a Long Short-Term Memory (LSTM) neural network. Users can upload their own historical stock data in CSV format, configure various model parameters, train the LSTM model, and visualize the actual vs. predicted stock prices.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages