CNN_Model / README.md
Kaylah072001's picture
Update README.md
9057102 verified
|
Raw
History Blame Contribute Delete
2.25 kB
# Stock Classification Model
This repository contains The Hybrid Image-Numerical Stock Prediction Model is a multi-input neural network designed to predict binary stock price movements (up/down) based on historical chart images and technical indicators. It processes both image data (stock charts) and numerical data (technical indicators like RSI, MACD, Bollinger Bands, ATR, and OBV) to make predictions.
---
## Features 🐾
- **High Accuracy**: Achieves a **test accuracy of 83.43%**!
---
## Performance Metrics πŸ“Š
### Final Results:
- **Test Accuracy**: `83.43%`
- **Validation Accuracy**: `83.33%`
- **Training Accuracy**: `79.82%`
---
## Dataset πŸ“‚
- **Source**: Stock graph images from opensource API yfinance.
- **Structure**:
- `dataset_even2/`: Contains all Bullish and Bearish Stock graph images.
- `train, test, val`
---
## Model Details 🧠
- **Architecture**: Architecture:
The model has a multi-input architecture with two branches:
Image input branch:
Input shape: (150, 150, 3)
Three Conv2D layers with ReLU activation and MaxPooling2D layers
Flattening layer at the end
Numerical input branch:
Input shape: (5,) (for 5 numerical features)
One Dense layer with 64 units and ReLU activation
The branches are then combined using concatenation, followed by:
Dense layer with 128 units and ReLU activation
Output Dense layer with 1 unit and sigmoid activation
- **Optimizer**: Adam optimizer.
- **Loss Function**: Binary crossentropy
---
## Usage πŸš€
### Loading the Model
```python
import torch
from tensorflow.keras.models import Model
import pickle
# Load the model
model = Model(inputs=[img_input, num_input], outputs=output)
num_features = model.fc.in_features
model.fc = torch.nn.Linear(num_features, 2)
model.load_state_dict(torch.load('stock_prediction_model.h5'))
model.eval()
# Load label mapping
with open('label_mapping.pkl', 'rb') as f:
label_mapping = pickle.load(f)
```
### Making Predictions
```python
from PIL import Image
from tensorflow.keras.preprocessing import transforms
# Define transforms
val_transform = transforms.Compose([
transforms.Resize((224, 224)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
])
```
---