File size: 2,247 Bytes
65fd3e0
cf2e5d3
65fd3e0
cf2e5d3
65fd3e0
cf2e5d3
65fd3e0
cf2e5d3
 
65fd3e0
cf2e5d3
65fd3e0
cf2e5d3
3f84e4b
cf2e5d3
1b75dad
 
 
3f84e4b
cf2e5d3
65fd3e0
cf2e5d3
 
 
762666b
 
65fd3e0
cf2e5d3
65fd3e0
cf2e5d3
1a1a353
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65fd3e0
cf2e5d3
65fd3e0
cf2e5d3
65fd3e0
cf2e5d3
 
 
 
 
65fd3e0
cf2e5d3
 
 
 
 
 
65fd3e0
cf2e5d3
 
 
65fd3e0
cf2e5d3
65fd3e0
cf2e5d3
 
 
 
65fd3e0
cf2e5d3
 
 
 
 
 
65fd3e0
cf2e5d3
65fd3e0
cf2e5d3
65fd3e0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86

# 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])
])

```

---