Skip to content

adhi29/image-classification

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Stock Movement Prediction using CNN

Overview

This project is a web application that uses a Convolutional Neural Network (CNN) to predict stock price movements (Up, Down, or Flat) based on uploaded stock chart images. The application is built using Streamlit and TensorFlow/Keras, with a Jupyter Notebook (stock_prediction_app.ipynb) containing the implementation.

Features

  • Upload stock chart images (JPG, PNG, JPEG) for analysis.
  • Predict stock price movement (Up, Down, or Flat) using a pre-trained CNN model.
  • Display training and test accuracy of the model.
  • Visualize the distribution of predicted classes for test data using a histogram.

Requirements

  • Python 3.8+
  • Streamlit
  • TensorFlow
  • Keras
  • NumPy
  • Matplotlib
  • Scikit-learn
  • Jupyter Notebook (optional, for running the notebook directly)

Installation

  1. Clone the repository:
    git clone <repository_url>
    cd <repository_directory>
  2. Install the required packages:
    pip install -r requirements.txt
  3. Ensure you have a dataset of stock chart images or modify the load_real_data function to load your own dataset.

Usage

  1. Run the Streamlit app:
    streamlit run stock_prediction_app.py
    Note: You may need to convert the Jupyter Notebook (stock_prediction_app.ipynb) to a Python script (stock_prediction_app.py) using a tool like jupytext or by manually copying the code into a .py file.
  2. Open the provided URL in your browser (typically http://localhost:8501).
  3. Upload a stock chart image to predict the stock movement (Up, Down, or Flat).
  4. View the prediction and the class distribution histogram for test data.

File Structure

  • stock_prediction_app.ipynb: Jupyter Notebook containing the main application code.
  • requirements.txt: List of required Python packages.
  • temp_image.png: Temporary file created when uploading an image (generated at runtime).

Model Details

  • Architecture: The CNN model consists of three convolutional layers with ReLU activation, each followed by max-pooling, a flatten layer, a dense layer with 256 units, a dropout layer (0.5), and a final dense layer with softmax activation for three classes (Up, Down, Flat).
  • Input: Images are resized to 224x224 pixels and normalized to [0, 1].
  • Training: The model is trained on a dummy dataset (replace with real stock chart images). It uses the Adam optimizer and categorical cross-entropy loss.
  • Output: Predictions are classified into three categories: Up (0), Down (1), or Flat (2).

Notes

  • The load_real_data function currently generates random data for demonstration. Replace it with a function to load actual stock chart images and corresponding labels.
  • Ensure the uploaded images are valid stock charts for accurate predictions.
  • The model is trained for 10 epochs with a batch size of 32. Adjust these parameters as needed for your dataset.
  • The application saves uploaded images temporarily as temp_image.png. Ensure write permissions in the working directory.
  • To run the notebook directly, use Jupyter Notebook or Jupyter Lab. To run as a Streamlit app, convert to a .py file.

About

as i interested in stock market i developed this for the analyzing the trend

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors